@@ -1172,19 +1172,30 @@ func TestPushImage(t *testing.T) {
1172
1172
}
1173
1173
1174
1174
// Then: re-running envbuilder with GET_CACHED_IMAGE should succeed
1175
- _ , err = runEnvbuilder (t , options {env : []string {
1175
+ ctrID , err : = runEnvbuilder (t , options {env : []string {
1176
1176
envbuilderEnv ("GIT_URL" , srv .URL ),
1177
1177
envbuilderEnv ("CACHE_REPO" , testRepo ),
1178
1178
envbuilderEnv ("GET_CACHED_IMAGE" , "1" ),
1179
1179
}})
1180
1180
require .NoError (t , err )
1181
1181
1182
- // When: we pull the image we just built
1182
+ // Then: the cached image ref should be emitted in the container logs
1183
1183
ctx , cancel := context .WithCancel (context .Background ())
1184
1184
t .Cleanup (cancel )
1185
1185
cli , err := client .NewClientWithOpts (client .FromEnv , client .WithAPIVersionNegotiation ())
1186
1186
require .NoError (t , err )
1187
1187
defer cli .Close ()
1188
+ logs , err := cli .ContainerLogs (ctx , ctrID , container.LogsOptions {
1189
+ ShowStdout : true ,
1190
+ ShowStderr : true ,
1191
+ })
1192
+ require .NoError (t , err )
1193
+ defer logs .Close ()
1194
+ logBytes , err := io .ReadAll (logs )
1195
+ require .NoError (t , err )
1196
+ require .Regexp (t , `ENVBUILDER_CACHED_IMAGE=(\S+)` , string (logBytes ))
1197
+
1198
+ // When: we pull the image we just built
1188
1199
rc , err := cli .ImagePull (ctx , ref .String (), image.PullOptions {})
1189
1200
require .NoError (t , err )
1190
1201
t .Cleanup (func () { _ = rc .Close () })
0 commit comments