mirror of
https://github.com/containrrr/watchtower.git
synced 2025-12-14 14:10:12 +01:00
Refactoring & renaming
This commit is contained in:
parent
3dd06cffb1
commit
00f2875abf
15 changed files with 254 additions and 233 deletions
68
container/container_test.go
Normal file
68
container/container_test.go
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
package container
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/samalba/dockerclient"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestName(t *testing.T) {
|
||||
c := Container{
|
||||
containerInfo: &dockerclient.ContainerInfo{Name: "foo"},
|
||||
}
|
||||
|
||||
name := c.Name()
|
||||
|
||||
assert.Equal(t, "foo", name)
|
||||
}
|
||||
|
||||
func TestLinks(t *testing.T) {
|
||||
c := Container{
|
||||
containerInfo: &dockerclient.ContainerInfo{
|
||||
HostConfig: &dockerclient.HostConfig{
|
||||
Links: []string{"foo:foo", "bar:bar"},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
links := c.Links()
|
||||
|
||||
assert.Equal(t, []string{"foo", "bar"}, links)
|
||||
}
|
||||
|
||||
func TestIsWatchtower_True(t *testing.T) {
|
||||
c := Container{
|
||||
containerInfo: &dockerclient.ContainerInfo{
|
||||
Config: &dockerclient.ContainerConfig{
|
||||
Labels: map[string]string{"com.centurylinklabs.watchtower": "true"},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
assert.True(t, c.IsWatchtower())
|
||||
}
|
||||
|
||||
func TestIsWatchtower_WrongLabelValue(t *testing.T) {
|
||||
c := Container{
|
||||
containerInfo: &dockerclient.ContainerInfo{
|
||||
Config: &dockerclient.ContainerConfig{
|
||||
Labels: map[string]string{"com.centurylinklabs.watchtower": "false"},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
assert.False(t, c.IsWatchtower())
|
||||
}
|
||||
|
||||
func TestIsWatchtower_NoLabel(t *testing.T) {
|
||||
c := Container{
|
||||
containerInfo: &dockerclient.ContainerInfo{
|
||||
Config: &dockerclient.ContainerConfig{
|
||||
Labels: map[string]string{},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
assert.False(t, c.IsWatchtower())
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue