-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathps_test.go
53 lines (46 loc) · 1.01 KB
/
ps_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
package dockercommand
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestShortDockerPs(t *testing.T) {
docker, err := NewDockerForTest()
if err != nil {
t.Fatalf("err: %s", err)
}
containers, err := docker.Ps(&PsOptions{All: true})
if err != nil {
t.Fatalf("err: %s", err)
}
assert.NotEmpty(t, containers)
assert.Len(t, containers, 2)
assert.Equal(t, containers[0].ID, "8dfafdbc3a40")
assert.Equal(t, containers[1].ID, "0236fd017853")
}
func TestLongDockerPs(t *testing.T) {
if testing.Short() {
t.Skip("skipping test in short mode.")
}
docker, err := NewDocker("")
if err != nil {
t.Fatalf("err: %s", err)
}
container, err := docker.Run(&RunOptions{
Image: "ubuntu",
Cmd: []string{"ls", "/"},
})
if err != nil {
t.Fatalf("err: %s", err)
}
containers, err := docker.Ps(&PsOptions{
All: true,
})
if err != nil {
t.Fatalf("err: %s", err)
}
assert.NotEmpty(t, containers)
err = cleanContainer(docker, container.ID())
if err != nil {
t.Fatalf("err: %s", err)
}
}