github.com/docker/app@v0.9.1-beta3.0.20210611140623-a48f773ab002/types/metadata/load_test.go (about) 1 package metadata 2 3 import ( 4 "fmt" 5 "testing" 6 7 "gotest.tools/assert" 8 is "gotest.tools/assert/cmp" 9 ) 10 11 func TestInvalidYAML(t *testing.T) { 12 _, err := Load([]byte("invalid yaml")) 13 assert.Check(t, is.ErrorContains(err, "failed to parse application metadata")) 14 } 15 16 func TestAllFields(t *testing.T) { 17 m := AppMetadata{ 18 Name: "testapp", 19 Version: "0.2.0", 20 Description: "something about this application", 21 Maintainers: []Maintainer{ 22 { 23 Name: "dev", 24 Email: "dev@example.com", 25 }, 26 }, 27 } 28 parsed, err := Load([]byte(fmt.Sprintf(`name: %s 29 version: %s 30 description: %s 31 maintainers: 32 - name: %s 33 email: %s 34 `, m.Name, m.Version, m.Description, m.Maintainers[0].Name, m.Maintainers[0].Email))) 35 assert.NilError(t, err) 36 assert.Check(t, is.DeepEqual(parsed, m)) 37 }