mirror of
https://github.com/containrrr/watchtower.git
synced 2025-12-15 14:40:13 +01:00
Support for --cleanup flag
The --cleanup flag will cause watchtower to automatically remove the old image after a container is restart with a new image.
This commit is contained in:
parent
b8ba80df2d
commit
dd80aa4a0d
10 changed files with 117 additions and 7 deletions
|
|
@ -399,3 +399,38 @@ func TestIsContainerStale_InspectImageError(t *testing.T) {
|
|||
assert.EqualError(t, err, "uh-oh")
|
||||
api.AssertExpectations(t)
|
||||
}
|
||||
|
||||
func TestRemoveImage_Success(t *testing.T) {
|
||||
c := Container{
|
||||
imageInfo: &dockerclient.ImageInfo{
|
||||
Id: "abc123",
|
||||
},
|
||||
}
|
||||
|
||||
api := mockclient.NewMockClient()
|
||||
api.On("RemoveImage", "abc123").Return([]*dockerclient.ImageDelete{}, nil)
|
||||
|
||||
client := DockerClient{api: api}
|
||||
err := client.RemoveImage(c)
|
||||
|
||||
assert.NoError(t, err)
|
||||
api.AssertExpectations(t)
|
||||
}
|
||||
|
||||
func TestRemoveImage_Error(t *testing.T) {
|
||||
c := Container{
|
||||
imageInfo: &dockerclient.ImageInfo{
|
||||
Id: "abc123",
|
||||
},
|
||||
}
|
||||
|
||||
api := mockclient.NewMockClient()
|
||||
api.On("RemoveImage", "abc123").Return([]*dockerclient.ImageDelete{}, errors.New("oops"))
|
||||
|
||||
client := DockerClient{api: api}
|
||||
err := client.RemoveImage(c)
|
||||
|
||||
assert.Error(t, err)
|
||||
assert.EqualError(t, err, "oops")
|
||||
api.AssertExpectations(t)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue