|
|
@ -5,7 +5,6 @@ import (
|
|
|
|
"testing"
|
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
|
|
|
|
"github.com/containrrr/watchtower/actions"
|
|
|
|
|
|
|
|
"github.com/containrrr/watchtower/pkg/container"
|
|
|
|
"github.com/containrrr/watchtower/pkg/container"
|
|
|
|
"github.com/containrrr/watchtower/pkg/container/mocks"
|
|
|
|
"github.com/containrrr/watchtower/pkg/container/mocks"
|
|
|
|
"github.com/docker/docker/api/types"
|
|
|
|
"github.com/docker/docker/api/types"
|
|
|
@ -44,7 +43,7 @@ var _ = Describe("the actions package", func() {
|
|
|
|
When("given an empty array", func() {
|
|
|
|
When("given an empty array", func() {
|
|
|
|
It("should not do anything", func() {
|
|
|
|
It("should not do anything", func() {
|
|
|
|
client.TestData.Containers = []container.Container{}
|
|
|
|
client.TestData.Containers = []container.Container{}
|
|
|
|
err := actions.CheckForMultipleWatchtowerInstances(client, false)
|
|
|
|
err := CheckForMultipleWatchtowerInstances(client, false)
|
|
|
|
Expect(err).NotTo(HaveOccurred())
|
|
|
|
Expect(err).NotTo(HaveOccurred())
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
@ -57,7 +56,7 @@ var _ = Describe("the actions package", func() {
|
|
|
|
"watchtower",
|
|
|
|
"watchtower",
|
|
|
|
time.Now()),
|
|
|
|
time.Now()),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
err := actions.CheckForMultipleWatchtowerInstances(client, false)
|
|
|
|
err := CheckForMultipleWatchtowerInstances(client, false)
|
|
|
|
Expect(err).NotTo(HaveOccurred())
|
|
|
|
Expect(err).NotTo(HaveOccurred())
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
@ -85,7 +84,7 @@ var _ = Describe("the actions package", func() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
It("should stop all but the latest one", func() {
|
|
|
|
It("should stop all but the latest one", func() {
|
|
|
|
err := actions.CheckForMultipleWatchtowerInstances(client, false)
|
|
|
|
err := CheckForMultipleWatchtowerInstances(client, false)
|
|
|
|
Expect(err).NotTo(HaveOccurred())
|
|
|
|
Expect(err).NotTo(HaveOccurred())
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
@ -112,12 +111,12 @@ var _ = Describe("the actions package", func() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
It("should try to delete the image if the cleanup flag is true", func() {
|
|
|
|
It("should try to delete the image if the cleanup flag is true", func() {
|
|
|
|
err := actions.CheckForMultipleWatchtowerInstances(client, true)
|
|
|
|
err := CheckForMultipleWatchtowerInstances(client, true)
|
|
|
|
Expect(err).NotTo(HaveOccurred())
|
|
|
|
Expect(err).NotTo(HaveOccurred())
|
|
|
|
Expect(client.TestData.TriedToRemoveImage).To(BeTrue())
|
|
|
|
Expect(client.TestData.TriedToRemoveImage).To(BeTrue())
|
|
|
|
})
|
|
|
|
})
|
|
|
|
It("should not try to delete the image if the cleanup flag is false", func() {
|
|
|
|
It("should not try to delete the image if the cleanup flag is false", func() {
|
|
|
|
err := actions.CheckForMultipleWatchtowerInstances(client, false)
|
|
|
|
err := CheckForMultipleWatchtowerInstances(client, false)
|
|
|
|
Expect(err).NotTo(HaveOccurred())
|
|
|
|
Expect(err).NotTo(HaveOccurred())
|
|
|
|
Expect(client.TestData.TriedToRemoveImage).To(BeFalse())
|
|
|
|
Expect(client.TestData.TriedToRemoveImage).To(BeFalse())
|
|
|
|
})
|
|
|
|
})
|