1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/image/tarexport/load_test.go
Josh Chorlton 654f854fae reject null manifests
Signed-off-by: Josh Chorlton <jchorlton@gmail.com>
2021-02-02 09:24:53 -08:00

37 lines
666 B
Go

package tarexport
import (
"testing"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
)
func TestValidateManifest(t *testing.T) {
cases := map[string]struct {
manifest []manifestItem
valid bool
errContains string
}{
"nil": {
manifest: nil,
valid: false,
errContains: "manifest cannot be null",
},
"non-nil": {
manifest: []manifestItem{},
valid: true,
},
}
for name, tc := range cases {
t.Run(name, func(t *testing.T) {
err := validateManifest(tc.manifest)
if tc.valid {
assert.Check(t, is.Nil(err))
} else {
assert.Check(t, is.ErrorContains(err, tc.errContains))
}
})
}
}