github.com/gophercloud/gophercloud@v1.11.0/openstack/container/v1/capsules/testing/template_test.go (about) 1 package testing 2 3 import ( 4 "testing" 5 6 "github.com/gophercloud/gophercloud/openstack/container/v1/capsules" 7 th "github.com/gophercloud/gophercloud/testhelper" 8 ) 9 10 func TestTemplateParsing(t *testing.T) { 11 templateJSON := new(capsules.Template) 12 templateJSON.Bin = []byte(ValidJSONTemplate) 13 err := templateJSON.Parse() 14 th.AssertNoErr(t, err) 15 th.AssertDeepEquals(t, ValidJSONTemplateParsed, templateJSON.Parsed) 16 17 templateYAML := new(capsules.Template) 18 templateYAML.Bin = []byte(ValidYAMLTemplate) 19 err = templateYAML.Parse() 20 th.AssertNoErr(t, err) 21 th.AssertDeepEquals(t, ValidYAMLTemplateParsed, templateYAML.Parsed) 22 23 templateInvalid := new(capsules.Template) 24 templateInvalid.Bin = []byte("Keep Austin Weird") 25 err = templateInvalid.Parse() 26 if err == nil { 27 t.Error("Template parsing did not catch invalid template") 28 } 29 }