github.com/webdestroya/awsmocker@v0.2.6/util_test.go (about) 1 package awsmocker 2 3 import ( 4 "testing" 5 6 "github.com/stretchr/testify/require" 7 ) 8 9 func TestInferContentType(t *testing.T) { 10 tables := []struct { 11 exp string 12 str string 13 }{ 14 {ContentTypeXML, "<Test>Thing</Test>"}, 15 {ContentTypeXML, "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\" ?>\n<Fake>Thing</Fake>"}, 16 {ContentTypeJSON, `{"test":"thing"}`}, 17 {ContentTypeJSON, `{}`}, 18 {ContentTypeText, `raw=thing`}, 19 } 20 21 for _, table := range tables { 22 require.Equal(t, table.exp, inferContentType(table.str)) 23 } 24 }