-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathclient_inputs_test.go
70 lines (59 loc) · 1.67 KB
/
client_inputs_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package dockertest
import (
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/filters"
. "gopkg.in/check.v1"
)
type ClientInputsTest struct{}
var _ = Suite(&ClientInputsTest{})
func (s *ClientInputsTest) TestAddEnvironmentVar(c *C) {
input := NewClientInput("test")
input.AddEnvironmentVar("foo", "bar")
c.Assert(input.Environment, DeepEquals, []string{"foo=bar"})
}
func (s *ClientInputsTest) TestSetLabel(c *C) {
input := NewClientInput("test")
input.SetLabel("foo", "bar")
value, ok := input.Labels["foo"]
c.Assert(ok, Equals, true)
c.Assert(value, Equals, "bar")
}
func (s *ClientInputsTest) TestRemoveLabel(c *C) {
input := NewClientInput("test")
input.SetLabel("foo", "bar")
input.RemoveLabel("foo")
_, ok := input.Labels["foo"]
c.Assert(ok, Equals, false)
}
func (s *ClientInputsTest) TestContainerConfig(c *C) {
input := NewClientInput("test")
input.SetLabel("foo", "bar")
c.Assert(input.ContainerConfig(), DeepEquals, &container.Config{
Image: "test",
Labels: map[string]string{
"foo": "bar",
"dockertest": "1",
},
})
}
func (s *ClientInputsTest) TestFilterArgs(c *C) {
input := NewClientInput("test")
input.SetLabel("foo", "bar")
input.Status = "running"
expected := filters.NewArgs()
expected.Add("ancestor", "test")
expected.Add("label", "dockertest=1")
expected.Add("label", "foo=bar")
expected.Add("status", "running")
c.Assert(input.FilterArgs(), DeepEquals, expected)
}
func (s *ClientInputsTest) TestNewClientInput(c *C) {
input := NewClientInput("test")
c.Assert(input, DeepEquals, &ClientInput{
Image: "test",
Ports: NewPorts(),
Labels: map[string]string{
"dockertest": "1",
},
})
}