github.com/moby/docker@v26.1.3+incompatible/image/tarexport/load_test.go (about) 1 package tarexport 2 3 import ( 4 "testing" 5 6 "gotest.tools/v3/assert" 7 is "gotest.tools/v3/assert/cmp" 8 ) 9 10 func TestValidateManifest(t *testing.T) { 11 cases := map[string]struct { 12 manifest []manifestItem 13 valid bool 14 errContains string 15 }{ 16 "nil": { 17 manifest: nil, 18 valid: false, 19 errContains: "manifest cannot be null", 20 }, 21 "non-nil": { 22 manifest: []manifestItem{}, 23 valid: true, 24 }, 25 } 26 27 for name, tc := range cases { 28 t.Run(name, func(t *testing.T) { 29 err := validateManifest(tc.manifest) 30 if tc.valid { 31 assert.Check(t, is.Nil(err)) 32 } else { 33 assert.Check(t, is.ErrorContains(err, tc.errContains)) 34 } 35 }) 36 } 37 }