mirror of
https://github.com/containrrr/watchtower.git
synced 2025-12-13 21:56:38 +01:00
fix linting and formatting
This commit is contained in:
parent
00715e4633
commit
4672811983
7 changed files with 30 additions and 31 deletions
|
|
@ -8,8 +8,8 @@ import (
|
|||
"github.com/containrrr/watchtower/pkg/container"
|
||||
"github.com/containrrr/watchtower/pkg/container/mocks"
|
||||
|
||||
cli "github.com/docker/docker/client"
|
||||
"github.com/docker/docker/api/types"
|
||||
cli "github.com/docker/docker/client"
|
||||
|
||||
. "github.com/containrrr/watchtower/internal/actions/mocks"
|
||||
. "github.com/onsi/ginkgo"
|
||||
|
|
@ -35,7 +35,7 @@ var _ = Describe("the actions package", func() {
|
|||
removeVolumes := false
|
||||
|
||||
client = CreateMockClient(
|
||||
&TestData {},
|
||||
&TestData{},
|
||||
dockerClient,
|
||||
pullImages,
|
||||
removeVolumes,
|
||||
|
|
@ -143,4 +143,4 @@ func createMockContainer(id string, name string, image string, created time.Time
|
|||
},
|
||||
}
|
||||
return *container.NewContainer(&content, nil)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,8 +20,8 @@ type MockClient struct {
|
|||
// TestData is the data used to perform the test
|
||||
type TestData struct {
|
||||
TriedToRemoveImageCount int
|
||||
NameOfContainerToKeep string
|
||||
Containers []container.Container
|
||||
NameOfContainerToKeep string
|
||||
Containers []container.Container
|
||||
}
|
||||
|
||||
// TriedToRemoveImage is a test helper function to check whether RemoveImageByID has been called
|
||||
|
|
@ -31,7 +31,7 @@ func (testdata *TestData) TriedToRemoveImage() bool {
|
|||
|
||||
// CreateMockClient creates a mock watchtower Client for usage in tests
|
||||
func CreateMockClient(data *TestData, api cli.CommonAPIClient, pullImages bool, removeVolumes bool) MockClient {
|
||||
return MockClient {
|
||||
return MockClient{
|
||||
data,
|
||||
api,
|
||||
pullImages,
|
||||
|
|
@ -56,6 +56,7 @@ func (client MockClient) StopContainer(c container.Container, d time.Duration) e
|
|||
func (client MockClient) StartContainer(c container.Container) (string, error) {
|
||||
return "", nil
|
||||
}
|
||||
|
||||
// RenameContainer is a mock method
|
||||
func (client MockClient) RenameContainer(c container.Container, s string) error {
|
||||
return nil
|
||||
|
|
@ -81,4 +82,3 @@ func (client MockClient) ExecuteCommand(containerID string, command string, time
|
|||
func (client MockClient) IsContainerStale(c container.Container) (bool, error) {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ func stopStaleContainer(container container.Container, client container.Client,
|
|||
return
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if err := client.StopContainer(container, params.Timeout); err != nil {
|
||||
log.Error(err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ import (
|
|||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
|
||||
var _ = Describe("the update action", func() {
|
||||
var dockerClient cli.CommonAPIClient
|
||||
var client MockClient
|
||||
|
|
@ -25,7 +24,6 @@ var _ = Describe("the update action", func() {
|
|||
cli.WithHTTPClient(server.Client()))
|
||||
})
|
||||
|
||||
|
||||
When("watchtower has been instructed to clean up", func() {
|
||||
BeforeEach(func() {
|
||||
pullImages := false
|
||||
|
|
@ -60,7 +58,7 @@ var _ = Describe("the update action", func() {
|
|||
When("there are multiple containers using the same image", func() {
|
||||
It("should only try to remove the image once", func() {
|
||||
|
||||
err := actions.Update(client, types.UpdateParams{ Cleanup: true })
|
||||
err := actions.Update(client, types.UpdateParams{Cleanup: true})
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(client.TestData.TriedToRemoveImageCount).To(Equal(1))
|
||||
})
|
||||
|
|
@ -76,7 +74,7 @@ var _ = Describe("the update action", func() {
|
|||
time.Now(),
|
||||
),
|
||||
)
|
||||
err := actions.Update(client, types.UpdateParams{ Cleanup: true })
|
||||
err := actions.Update(client, types.UpdateParams{Cleanup: true})
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(client.TestData.TriedToRemoveImageCount).To(Equal(2))
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue