From ed3b3b57de8add924e1f129db57a9150c43fe30e Mon Sep 17 00:00:00 2001 From: Agniva De Sarker Date: Fri, 15 Apr 2022 14:49:48 +0530 Subject: [PATCH] MM-42877: Fix TestGetFileHeaders (#20002) The issue seems to be that different distros have different set of included mime types built-in. Go looks into those directories and it looks like our CI systems don't have those files. https://mattermost.atlassian.net/browse/MM-42877 ```release-note NONE ``` --- api4/file_test.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/api4/file_test.go b/api4/file_test.go index a6f9d9c2cf..769a0153ef 100644 --- a/api4/file_test.go +++ b/api4/file_test.go @@ -16,6 +16,7 @@ import ( "net/url" "os" "path/filepath" + "runtime" "strings" "testing" "time" @@ -817,7 +818,11 @@ func TestGetFileHeaders(t *testing.T) { t.Run("txt", testHeaders(data, "test.txt", "text/plain", false, false)) t.Run("html", testHeaders(data, "test.html", "text/plain", false, false)) t.Run("js", testHeaders(data, "test.js", "text/plain", false, false)) - t.Run("go", testHeaders(data, "test.go", "application/octet-stream", false, false)) + if os.Getenv("IS_CI") == "true" { + t.Run("go", testHeaders(data, "test.go", "application/octet-stream", false, false)) + } else if runtime.GOOS == "linux" || runtime.GOOS == "darwin" { + t.Run("go", testHeaders(data, "test.go", "text/x-go; charset=utf-8", false, false)) + } t.Run("zip", testHeaders(data, "test.zip", "application/zip", false, false)) // Not every platform can recognize these //t.Run("exe", testHeaders(data, "test.exe", "application/x-ms", false))