diff --git a/.gitignore b/.gitignore index 817676e..33c0635 100644 --- a/.gitignore +++ b/.gitignore @@ -13,10 +13,11 @@ # Dependency directories (remove the comment below to include it) exhaust/ +builds/ /.idea/.gitignore /.idea/misc.xml /.idea/modules.xml /.idea/vcs.xml /.idea/webp_server_go.iml remote-raw/ -coverage.txt \ No newline at end of file +coverage.txt diff --git a/router_test.go b/router_test.go index f294555..c3205f6 100644 --- a/router_test.go +++ b/router_test.go @@ -5,13 +5,14 @@ package main import ( - "github.com/gofiber/fiber/v2" - "github.com/stretchr/testify/assert" "io/ioutil" "net/http" "net/http/httptest" "os" "testing" + + "github.com/gofiber/fiber/v2" + "github.com/stretchr/testify/assert" ) var ( @@ -73,7 +74,7 @@ func TestConvert(t *testing.T) { "http://127.0.0.1:3333/webp_server.bmp": "image/webp", "http://127.0.0.1:3333/webp_server.png": "image/webp", "http://127.0.0.1:3333/empty.jpg": "", - "http://127.0.0.1:3333/png.jpg": "image/webp", + "http://127.0.0.1:3333/png.jpg": "image/png", "http://127.0.0.1:3333/12314.jpg": "", "http://127.0.0.1:3333/dir1/inside.jpg": "image/webp", "http://127.0.0.1:3333/%e5%a4%aa%e7%a5%9e%e5%95%a6.png": "image/webp", @@ -116,11 +117,10 @@ func TestConvertNotAllowed(t *testing.T) { var app = fiber.New() app.Get("/*", convert) - // not allowed, but we have the file + // not allowed, but we have the file, this should return File extension not allowed url := "http://127.0.0.1:3333/webp_server.bmp" _, data := requestToServer(url, app, chromeUA, acceptWebP) - contentType := getFileContentType(data) - assert.Equal(t, "image/bmp", contentType) + assert.Contains(t, string(data), "File extension not allowed") // not allowed, random file url = url + "hagdgd"