@@ -39,6 +39,7 @@ func TestComposeBuild(t *testing.T) {
39
39
// Make sure we shard the image name to something unique to the test to avoid conflicts with other tests
40
40
imageSvc0 := data .Identifier ("svc0" )
41
41
imageSvc1 := data .Identifier ("svc1" )
42
+ imageSvc2 := data .Identifier ("svc2" )
42
43
43
44
// We are not going to run them, so, ports conflicts should not matter here
44
45
dockerComposeYAML := fmt .Sprintf (`
@@ -51,14 +52,21 @@ services:
51
52
svc1:
52
53
build: .
53
54
image: %s
54
- ` , imageSvc0 , imageSvc1 )
55
+ svc2:
56
+ image: %s
57
+ build:
58
+ context: .
59
+ dockerfile_inline: |
60
+ FROM %s
61
+ ` , imageSvc0 , imageSvc1 , imageSvc2 , testutil .CommonImage )
55
62
56
63
data .Temp ().Save (dockerComposeYAML , "compose.yaml" )
57
64
data .Temp ().Save (dockerfile , "Dockerfile" )
58
65
59
66
data .Labels ().Set ("composeYaml" , data .Temp ().Path ("compose.yaml" ))
60
67
data .Labels ().Set ("imageSvc0" , imageSvc0 )
61
68
data .Labels ().Set ("imageSvc1" , imageSvc1 )
69
+ data .Labels ().Set ("imageSvc2" , imageSvc2 )
62
70
}
63
71
64
72
testCase .SubTests = []* test.Case {
@@ -76,22 +84,41 @@ services:
76
84
Output : expect .All (
77
85
expect .Contains (data .Labels ().Get ("imageSvc0" )),
78
86
expect .DoesNotContain (data .Labels ().Get ("imageSvc1" )),
87
+ expect .DoesNotContain (data .Labels ().Get ("imageSvc2" )),
88
+ ),
89
+ }
90
+ },
91
+ },
92
+ {
93
+ Description : "build svc2" ,
94
+ NoParallel : true ,
95
+ Setup : func (data test.Data , helpers test.Helpers ) {
96
+ helpers .Ensure ("compose" , "-f" , data .Labels ().Get ("composeYaml" ), "build" , "svc2" )
97
+ },
98
+
99
+ Command : test .Command ("images" ),
100
+
101
+ Expected : func (data test.Data , helpers test.Helpers ) * test.Expected {
102
+ return & test.Expected {
103
+ Output : expect .All (
104
+ expect .Contains (data .Labels ().Get ("imageSvc2" )),
105
+ expect .DoesNotContain (data .Labels ().Get ("imageSvc1" )),
79
106
),
80
107
}
81
108
},
82
109
},
83
110
{
84
- Description : "build svc0 and svc1" ,
111
+ Description : "build svc0, svc1, svc2 " ,
85
112
NoParallel : true ,
86
113
Setup : func (data test.Data , helpers test.Helpers ) {
87
- helpers .Ensure ("compose" , "-f" , data .Labels ().Get ("composeYaml" ), "build" , "svc0" , "svc1" )
114
+ helpers .Ensure ("compose" , "-f" , data .Labels ().Get ("composeYaml" ), "build" , "svc0" , "svc1" , "svc2" )
88
115
},
89
116
90
117
Command : test .Command ("images" ),
91
118
92
119
Expected : func (data test.Data , helpers test.Helpers ) * test.Expected {
93
120
return & test.Expected {
94
- Output : expect .Contains (data .Labels ().Get ("imageSvc0" ), data .Labels ().Get ("imageSvc1" )),
121
+ Output : expect .Contains (data .Labels ().Get ("imageSvc0" ), data .Labels ().Get ("imageSvc1" ), data . Labels (). Get ( "imageSvc2" ) ),
95
122
}
96
123
},
97
124
},
@@ -122,7 +149,7 @@ services:
122
149
123
150
testCase .Cleanup = func (data test.Data , helpers test.Helpers ) {
124
151
if data .Labels ().Get ("imageSvc0" ) != "" {
125
- helpers .Anyhow ("rmi" , data .Labels ().Get ("imageSvc0" ), data .Labels ().Get ("imageSvc1" ))
152
+ helpers .Anyhow ("rmi" , data .Labels ().Get ("imageSvc0" ), data .Labels ().Get ("imageSvc1" ), data . Labels (). Get ( "imageSvc2" ) )
126
153
}
127
154
}
128
155
0 commit comments