github.com/ijc/docker-app@v0.6.1-0.20181012090447-c7ca8bc483fb/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 Namespace: "testnamespace", 22 Maintainers: []Maintainer{ 23 { 24 Name: "bob", 25 Email: "bob@aol.com", 26 }, 27 }, 28 } 29 parsed, err := Load([]byte(fmt.Sprintf(`name: %s 30 version: %s 31 description: %s 32 namespace: %s 33 maintainers: 34 - name: %s 35 email: %s 36 `, m.Name, m.Version, m.Description, m.Namespace, m.Maintainers[0].Name, m.Maintainers[0].Email))) 37 assert.NilError(t, err) 38 assert.Check(t, is.DeepEqual(parsed, m)) 39 }