From 66fda9af160915a9d15e40f57be08bf1125ddfc3 Mon Sep 17 00:00:00 2001 From: Davor Kapsa Date: Wed, 3 Oct 2018 20:54:11 +0200 Subject: [PATCH] add TestGetMimeType Signed-off-by: Davor Kapsa --- utils_test.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/utils_test.go b/utils_test.go index a1b39cb8..928fe409 100644 --- a/utils_test.go +++ b/utils_test.go @@ -92,6 +92,24 @@ func (s *EnryTestSuite) TestIsImage() { } } +func (s *EnryTestSuite) TestGetMimeType() { + tests := []struct { + name string + path string + lang string + expected string + }{ + {name: "TestGetMimeType_1", path: "text.txt", lang: "", expected: "text/plain"}, + {name: "TestGetMimeType_2", path: "file.go", lang: "Go", expected: "text/x-go"}, + {name: "TestGetMimeType_3", path: "image.png", lang: "", expected: "image/png"}, + } + + for _, test := range tests { + is := GetMimeType(test.path, test.lang) + assert.Equal(s.T(), is, test.expected, fmt.Sprintf("%v: is = %v, expected: %v", test.name, is, test.expected)) + } +} + func (s *EnryTestSuite) TestIsConfiguration() { tests := []struct { name string