diff --git a/media/mediaType.go b/media/mediaType.go index 18af666d59a..819de9d8028 100644 --- a/media/mediaType.go +++ b/media/mediaType.go @@ -274,6 +274,8 @@ var DefaultTypes = Types{ YAMLType, TOMLType, PNGType, + GIFType, + BMPType, JPEGType, WEBPType, AVIType, @@ -289,6 +291,15 @@ var DefaultTypes = Types{ func init() { sort.Sort(DefaultTypes) + + // Sanity check. + seen := make(map[Type]bool) + for _, t := range DefaultTypes { + if seen[t] { + panic(fmt.Sprintf("MediaType %s duplicated in list", t)) + } + seen[t] = true + } } // Types is a slice of media types. diff --git a/media/mediaType_test.go b/media/mediaType_test.go index 8c739813d79..cd4439fe79b 100644 --- a/media/mediaType_test.go +++ b/media/mediaType_test.go @@ -15,6 +15,7 @@ package media import ( "encoding/json" + "fmt" "io/ioutil" "path/filepath" "sort" @@ -63,7 +64,7 @@ func TestDefaultTypes(t *testing.T) { } - c.Assert(len(DefaultTypes), qt.Equals, 31) + c.Assert(len(DefaultTypes), qt.Equals, 33) } func TestGetByType(t *testing.T) { @@ -193,6 +194,7 @@ func TestFromContent(t *testing.T) { content, err := ioutil.ReadFile(filename) c.Assert(err, qt.IsNil) ext := strings.TrimPrefix(paths.Ext(filename), ".") + fmt.Println("=>", ext) expected, _, found := mtypes.GetFirstBySuffix(ext) c.Assert(found, qt.IsTrue) got := FromContent(mtypes, ext, content) diff --git a/media/testdata/resource.bmp b/media/testdata/resource.bmp new file mode 100644 index 00000000000..19759b33d22 Binary files /dev/null and b/media/testdata/resource.bmp differ diff --git a/media/testdata/resource.gif b/media/testdata/resource.gif new file mode 100644 index 00000000000..9549c0b9d3f Binary files /dev/null and b/media/testdata/resource.gif differ