@@ -57,9 +57,10 @@ import (
5757)
5858
5959const (
60- testContainerLabel = "envbox-integration-test"
61- testImageAlpine = "localhost:5000/envbuilder-test-alpine:latest"
62- testImageUbuntu = "localhost:5000/envbuilder-test-ubuntu:latest"
60+ testContainerLabel = "envbox-integration-test"
61+ testImageAlpine = "localhost:5000/envbuilder-test-alpine:latest"
62+ testImageUbuntu = "localhost:5000/envbuilder-test-ubuntu:latest"
63+ testImageBlobUnknown = "localhost:5000/envbuilder-test-blob-unknown:latest"
6364
6465 // nolint:gosec // Throw-away key for testing. DO NOT REUSE.
6566 testSSHKey = `-----BEGIN OPENSSH PRIVATE KEY-----
@@ -2354,6 +2355,38 @@ USER devalot
23542355 }
23552356 require .Fail (t , "expected pid 1 to be running as devalot" )
23562357 })
2358+
2359+ t .Run ("PushDuplicateLayersNoBlobUnknown" , func (t * testing.T ) {
2360+ t .Parallel ()
2361+
2362+ srv := gittest .CreateGitServer (t , gittest.Options {
2363+ Files : map [string ]string {
2364+ ".devcontainer/Dockerfile" : fmt .Sprintf (`FROM %s
2365+ USER root
2366+ RUN echo "hi i r empty"
2367+ RUN echo "who u"
2368+ ` , testImageBlobUnknown ),
2369+ ".devcontainer/devcontainer.json" : `{
2370+ "name": "Test",
2371+ "build": {
2372+ "dockerfile": "Dockerfile"
2373+ },
2374+ }` ,
2375+ },
2376+ })
2377+
2378+ // NOTE(mafredri): The in-memory registry doesn't catch this error so we
2379+ // have to use registry:2.
2380+ ref , err := name .ParseReference (fmt .Sprintf ("localhost:5000/test-blob-unknown-%s" , uuid .NewString ()))
2381+ require .NoError (t , err )
2382+ opts := []string {
2383+ envbuilderEnv ("GIT_URL" , srv .URL ),
2384+ envbuilderEnv ("CACHE_REPO" , ref .String ()),
2385+ envbuilderEnv ("VERBOSE" , "1" ),
2386+ }
2387+
2388+ _ = pushImage (t , ref , nil , opts ... )
2389+ })
23572390}
23582391
23592392func TestChownHomedir (t * testing.T ) {
@@ -2532,6 +2565,8 @@ func getCachedImage(ctx context.Context, t *testing.T, cli *client.Client, env .
25322565}
25332566
25342567func startContainerFromRef (ctx context.Context , t * testing.T , cli * client.Client , ref name.Reference ) container.CreateResponse {
2568+ t .Helper ()
2569+
25352570 // Ensure that we can pull the image.
25362571 rc , err := cli .ImagePull (ctx , ref .String (), image.PullOptions {})
25372572 require .NoError (t , err )
0 commit comments