@@ -7,52 +7,54 @@ import (
7
7
8
8
"github.com/docker/docker/api/types/container"
9
9
"github.com/docker/docker/api/types/network"
10
- "github.com/stretchr/testify/require"
10
+ "github.com/docker/docker/integration/util/request"
11
+ "github.com/docker/docker/pkg/testutil"
11
12
)
12
13
13
- func TestAPICreateWithNotExistImage (t * testing.T ) {
14
+ func TestCreateFailsWhenIdentifierDoesNotExist (t * testing.T ) {
14
15
defer setupTest (t )()
15
- clt := createClient (t )
16
+ client := request . NewAPIClient (t )
16
17
17
18
testCases := []struct {
19
+ doc string
18
20
image string
19
21
expectedError string
20
22
}{
21
23
{
24
+ doc : "image and tag" ,
22
25
image : "test456:v1" ,
23
26
expectedError : "No such image: test456:v1" ,
24
27
},
25
28
{
29
+ doc : "image no tag" ,
26
30
image : "test456" ,
27
31
expectedError : "No such image: test456" ,
28
32
},
29
33
{
34
+ doc : "digest" ,
30
35
image : "sha256:0cb40641836c461bc97c793971d84d758371ed682042457523e4ae701efeaaaa" ,
31
36
expectedError : "No such image: sha256:0cb40641836c461bc97c793971d84d758371ed682042457523e4ae701efeaaaa" ,
32
37
},
33
38
}
34
39
35
- for index , tc := range testCases {
40
+ for _ , tc := range testCases {
36
41
tc := tc
37
- t .Run (strconv . Itoa ( index ) , func (t * testing.T ) {
42
+ t .Run (tc . doc , func (t * testing.T ) {
38
43
t .Parallel ()
39
- _ , err := clt .ContainerCreate (context .Background (),
40
- & container.Config {
41
- Image : tc .image ,
42
- },
44
+ _ , err := client .ContainerCreate (context .Background (),
45
+ & container.Config {Image : tc .image },
43
46
& container.HostConfig {},
44
47
& network.NetworkingConfig {},
45
48
"foo" ,
46
49
)
47
- require .Error (t , err )
48
- require .Contains (t , err .Error (), tc .expectedError )
50
+ testutil .ErrorContains (t , err , tc .expectedError )
49
51
})
50
52
}
51
53
}
52
54
53
- func TestAPICreateEmptyEnv (t * testing.T ) {
55
+ func TestCreateWithInvalidEnv (t * testing.T ) {
54
56
defer setupTest (t )()
55
- clt := createClient (t )
57
+ client := request . NewAPIClient (t )
56
58
57
59
testCases := []struct {
58
60
env string
@@ -76,7 +78,7 @@ func TestAPICreateEmptyEnv(t *testing.T) {
76
78
tc := tc
77
79
t .Run (strconv .Itoa (index ), func (t * testing.T ) {
78
80
t .Parallel ()
79
- _ , err := clt .ContainerCreate (context .Background (),
81
+ _ , err := client .ContainerCreate (context .Background (),
80
82
& container.Config {
81
83
Image : "busybox" ,
82
84
Env : []string {tc .env },
@@ -85,8 +87,7 @@ func TestAPICreateEmptyEnv(t *testing.T) {
85
87
& network.NetworkingConfig {},
86
88
"foo" ,
87
89
)
88
- require .Error (t , err )
89
- require .Contains (t , err .Error (), tc .expectedError )
90
+ testutil .ErrorContains (t , err , tc .expectedError )
90
91
})
91
92
}
92
93
}
0 commit comments