@@ -30,6 +30,7 @@ import (
30
30
"github.com/docker/docker/api/types"
31
31
"github.com/docker/docker/api/types/container"
32
32
"github.com/docker/docker/api/types/filters"
33
+ "github.com/docker/docker/api/types/image"
33
34
"github.com/docker/docker/client"
34
35
"github.com/docker/docker/pkg/stdcopy"
35
36
"github.com/go-git/go-billy/v5/memfs"
@@ -1370,7 +1371,7 @@ func TestEmbedBinaryImage(t *testing.T) {
1370
1371
})
1371
1372
1372
1373
testReg := setupInMemoryRegistry (t , setupInMemoryRegistryOpts {})
1373
- testRepo := testReg + "/test"
1374
+ testRepo := testReg + "/test-embed-binary-image "
1374
1375
ref , err := name .ParseReference (testRepo + ":latest" )
1375
1376
require .NoError (t , err )
1376
1377
@@ -1384,13 +1385,42 @@ func TestEmbedBinaryImage(t *testing.T) {
1384
1385
_ , err = remote .Image (ref )
1385
1386
require .NoError (t , err , "expected image to be present after build + push" )
1386
1387
1387
- ctr , err := runEnvbuilder (t , options {env : []string {
1388
- envbuilderEnv ("FALLBACK_IMAGE" , ref .String ()),
1389
- }})
1388
+ ctx := context .Background ()
1389
+ cli , err := client .NewClientWithOpts (client .FromEnv , client .WithAPIVersionNegotiation ())
1390
+ require .NoError (t , err )
1391
+ t .Cleanup (func () {
1392
+ cli .Close ()
1393
+ })
1394
+
1395
+ // Pull the image we just built
1396
+ rc , err := cli .ImagePull (ctx , ref .String (), image.PullOptions {})
1397
+ require .NoError (t , err )
1398
+ t .Cleanup (func () { _ = rc .Close () })
1399
+ _ , err = io .ReadAll (rc )
1400
+ require .NoError (t , err )
1401
+
1402
+ // Run it
1403
+ ctr , err := cli .ContainerCreate (ctx , & container.Config {
1404
+ Image : ref .String (),
1405
+ Cmd : []string {"sleep" , "infinity" },
1406
+ Labels : map [string ]string {
1407
+ testContainerLabel : "true" ,
1408
+ },
1409
+ }, nil , nil , nil , "" )
1410
+ require .NoError (t , err )
1411
+ t .Cleanup (func () {
1412
+ _ = cli .ContainerRemove (ctx , ctr .ID , container.RemoveOptions {
1413
+ RemoveVolumes : true ,
1414
+ Force : true ,
1415
+ })
1416
+ })
1417
+ err = cli .ContainerStart (ctx , ctr .ID , container.StartOptions {})
1390
1418
require .NoError (t , err )
1391
1419
1392
- out := execContainer (t , ctr , "[[ -f \" /.envbuilder/bin/envbuilder\" ]] && echo \" exists\" " )
1420
+ out := execContainer (t , ctr . ID , "[[ -f \" /.envbuilder/bin/envbuilder\" ]] && echo \" exists\" " )
1393
1421
require .Equal (t , "exists" , strings .TrimSpace (out ))
1422
+ out = execContainer (t , ctr .ID , "cat /root/date.txt" )
1423
+ require .NotEmpty (t , strings .TrimSpace (out ))
1394
1424
}
1395
1425
1396
1426
type setupInMemoryRegistryOpts struct {
0 commit comments