Skip to content

Commit

Permalink
make all tests use NewClient instead of creating a struct pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
simskij committed Apr 23, 2021
1 parent 3aaf7a2 commit 68b5fb6
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions pkg/container/container_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,27 +30,28 @@ var _ = Describe("the container", func() {
Describe("WarnOnHeadPullFailed", func(){
containerUnknown := *mockContainerWithImageName("unknown.repo/prefix/imagename:latest")
containerKnown := *mockContainerWithImageName("docker.io/prefix/imagename:latest")

When("warn on head failure is set to \"always\"", func() {
clientWarnAlways := NewClient(false, false, false, false, false, "always")
c := NewClient(false, false, false, false, false, "always")
It("should always return true", func() {
Expect(clientWarnAlways.WarnOnHeadPullFailed(containerUnknown)).To(BeTrue())
Expect(clientWarnAlways.WarnOnHeadPullFailed(containerKnown)).To(BeTrue())
Expect(c.WarnOnHeadPullFailed(containerUnknown)).To(BeTrue())
Expect(c.WarnOnHeadPullFailed(containerKnown)).To(BeTrue())
})
})
When("warn on head failure is set to \"auto\"", func() {
clientWarnAuto := dockerClient{warnOnHeadFailed: "auto"}
c := NewClient(false, false, false, false, false, "auto")
It("should always return true", func() {
Expect(clientWarnAuto.WarnOnHeadPullFailed(containerUnknown)).To(BeFalse())
Expect(c.WarnOnHeadPullFailed(containerUnknown)).To(BeFalse())
})
It("should", func() {
Expect(clientWarnAuto.WarnOnHeadPullFailed(containerKnown)).To(BeTrue())
Expect(c.WarnOnHeadPullFailed(containerKnown)).To(BeTrue())
})
})
When("warn on head failure is set to \"never\"", func() {
clientWarnNever := dockerClient{warnOnHeadFailed: "never"}
c := NewClient(false, false, false, false, false, "never")
It("should never return true", func() {
Expect(clientWarnNever.WarnOnHeadPullFailed(containerUnknown)).To(BeFalse())
Expect(clientWarnNever.WarnOnHeadPullFailed(containerKnown)).To(BeFalse())
Expect(c.WarnOnHeadPullFailed(containerUnknown)).To(BeFalse())
Expect(c.WarnOnHeadPullFailed(containerKnown)).To(BeFalse())
})
})
})
Expand Down

0 comments on commit 68b5fb6

Please sign in to comment.