github.com/lmorg/murex@v0.0.0-20240217211045-e081c89cd4ef/lang/define_mime_test.go (about) 1 package lang_test 2 3 import ( 4 "testing" 5 6 "github.com/lmorg/murex/lang" 7 "github.com/lmorg/murex/lang/types" 8 "github.com/lmorg/murex/test/count" 9 ) 10 11 func TestMimeToMurex_appPlusJson(t *testing.T) { 12 type testT struct { 13 Mime string 14 DataType string 15 } 16 17 tests := []testT{ 18 { 19 Mime: "application/json", 20 DataType: types.Json, 21 }, 22 { 23 Mime: "application/vnd.contentful.management.v1+json", 24 DataType: types.Json, 25 }, 26 { 27 Mime: "text/bob", 28 DataType: types.String, 29 }, 30 { 31 Mime: "foo/bar", 32 DataType: types.Generic, 33 }, 34 } 35 36 count.Tests(t, len(tests)) 37 38 for i, test := range tests { 39 dt := lang.MimeToMurex(test.Mime) 40 41 if dt != test.DataType { 42 t.Errorf("Mime convertion failed in test %d", i) 43 t.Logf("Mime: '%s'", test.Mime) 44 t.Logf("Expected: '%s'", test.DataType) 45 t.Logf("Actual: '%s'", dt) 46 } 47 } 48 }