mirror of
https://github.com/containrrr/watchtower.git
synced 2025-09-21 21:30:48 +02:00
fix some errors and clean up
This commit is contained in:
parent
c1a0da9a9d
commit
98c60d7441
4 changed files with 12 additions and 61 deletions
|
@ -9,6 +9,7 @@ import (
|
|||
"github.com/containrrr/watchtower/pkg/container/mocks"
|
||||
|
||||
cli "github.com/docker/docker/client"
|
||||
"github.com/docker/docker/api/types"
|
||||
|
||||
. "github.com/containrrr/watchtower/internal/actions/mocks"
|
||||
. "github.com/onsi/ginkgo"
|
||||
|
@ -142,52 +143,4 @@ func createMockContainer(id string, name string, image string, created time.Time
|
|||
},
|
||||
}
|
||||
return *container.NewContainer(&content, nil)
|
||||
}
|
||||
|
||||
type mockClient struct {
|
||||
TestData *TestData
|
||||
api cli.CommonAPIClient
|
||||
pullImages bool
|
||||
removeVolumes bool
|
||||
}
|
||||
|
||||
type TestData struct {
|
||||
TriedToRemoveImage bool
|
||||
NameOfContainerToKeep string
|
||||
Containers []container.Container
|
||||
}
|
||||
|
||||
func (client mockClient) ListContainers(f t.Filter) ([]container.Container, error) {
|
||||
return client.TestData.Containers, nil
|
||||
}
|
||||
|
||||
func (client mockClient) StopContainer(c container.Container, d time.Duration) error {
|
||||
if c.Name() == client.TestData.NameOfContainerToKeep {
|
||||
return errors.New("tried to stop the instance we want to keep")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (client mockClient) StartContainer(c container.Container) (string, error) {
|
||||
panic("Not implemented")
|
||||
}
|
||||
|
||||
func (client mockClient) RenameContainer(c container.Container, s string) error {
|
||||
panic("Not implemented")
|
||||
}
|
||||
|
||||
func (client mockClient) RemoveImage(c container.Container) error {
|
||||
client.TestData.TriedToRemoveImage = true
|
||||
return nil
|
||||
}
|
||||
|
||||
func (client mockClient) GetContainer(containerID string) (container.Container, error) {
|
||||
return container.Container{}, nil
|
||||
}
|
||||
|
||||
func (client mockClient) ExecuteCommand(containerID string, command string, timeout int) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (client mockClient) IsContainerStale(c container.Container) (bool, error) {
|
||||
panic("Not implemented")
|
||||
}
|
||||
}
|
|
@ -73,7 +73,7 @@ func (client MockClient) GetContainer(containerID string) (container.Container,
|
|||
}
|
||||
|
||||
// ExecuteCommand is a mock method
|
||||
func (client MockClient) ExecuteCommand(containerID string, command string) error {
|
||||
func (client MockClient) ExecuteCommand(containerID string, command string, timeout int) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue