Channels/api4 testing improvements (#22938)
* api4/post_test: fix missing TearDown * api4/plugin_test: dont test timeout, saving 120s * api4/channel_test: dont try to delete town square * api4/channel_test: check public channel names deterministically * api4/file_test: fix darwin assertions on go files * api4/notify_admin_test: fix expect/actual order * api4/team_test: make TestGetAllTeams deterministic * api4/plugin_test: avoid nested test helpers * api4/post_test: avoid nested test helpers * api4/websocket_test: externalize log buffer * testlib/helper: unset common env * linting issues * simplify TestGetFileHeaders * team_test: leverage ElementsMatch
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
dd2b1db420
Коммит
89f2ebc836
@@ -15,7 +15,6 @@ import (
|
||||
"net/url"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
@@ -790,6 +789,12 @@ func TestGetFileHeaders(t *testing.T) {
|
||||
t.Skip("skipping because no file driver is enabled")
|
||||
}
|
||||
|
||||
CheckStartsWith := func(tb testing.TB, value, prefix, message string) {
|
||||
tb.Helper()
|
||||
|
||||
require.True(tb, strings.HasPrefix(value, prefix), fmt.Sprintf("%s: %s", message, value))
|
||||
}
|
||||
|
||||
testHeaders := func(data []byte, filename string, expectedContentType string, getInline bool, loadFile bool) func(*testing.T) {
|
||||
return func(t *testing.T) {
|
||||
if loadFile {
|
||||
@@ -832,11 +837,8 @@ 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))
|
||||
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))
|
||||
}
|
||||
// *.go are categorized differently by different platforms
|
||||
// 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))
|
||||
|
||||
Ссылка в новой задаче
Block a user