Passing t to all tests setup functions (#13841)
* Passing t to all tests setup functions * Fixing build
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
3b732fe257
Коммит
1d1ab03c38
@@ -34,11 +34,11 @@ func TestUpdateConfig(t *testing.T) {
|
||||
|
||||
th.App.AddConfigListener(func(old, current *model.Config) {
|
||||
assert.Equal(t, prev, *old.ServiceSettings.SiteURL)
|
||||
assert.Equal(t, "foo", *current.ServiceSettings.SiteURL)
|
||||
assert.Equal(t, "http://foo.com", *current.ServiceSettings.SiteURL)
|
||||
})
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
*cfg.ServiceSettings.SiteURL = "foo"
|
||||
*cfg.ServiceSettings.SiteURL = "http://foo.com"
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -4,14 +4,15 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"github.com/mattermost/mattermost-server/v5/model"
|
||||
)
|
||||
|
||||
func TestCheckIfRolesGrantPermission(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
cases := []struct {
|
||||
|
||||
@@ -23,10 +23,10 @@ func TestBusySet(t *testing.T) {
|
||||
|
||||
require.False(t, busy.IsBusy())
|
||||
|
||||
busy.Set(time.Second * 3)
|
||||
busy.Set(time.Millisecond * 100)
|
||||
require.True(t, busy.IsBusy())
|
||||
require.True(t, compareBusyState(t, busy, cluster.Busy))
|
||||
// should automatically expire after 3s.
|
||||
// should automatically expire after 100ms.
|
||||
require.Eventually(t, isNotBusy, time.Second*15, time.Millisecond*20)
|
||||
// allow a moment for cluster to sync.
|
||||
require.Eventually(t, func() bool { return compareBusyState(t, busy, cluster.Busy) }, time.Second*15, time.Millisecond*20)
|
||||
|
||||
@@ -51,20 +51,20 @@ func TestConfigListener(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAsymmetricSigningKey(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
assert.NotNil(t, th.App.AsymmetricSigningKey())
|
||||
assert.NotEmpty(t, th.App.ClientConfig()["AsymmetricSigningPublicKey"])
|
||||
}
|
||||
|
||||
func TestPostActionCookieSecret(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
assert.Equal(t, 32, len(th.App.PostActionCookieSecret()))
|
||||
}
|
||||
|
||||
func TestClientConfigWithComputed(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
config := th.App.ClientConfigWithComputed()
|
||||
|
||||
@@ -68,7 +68,7 @@ func TestDiagnostics(t *testing.T) {
|
||||
t.SkipNow()
|
||||
}
|
||||
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
type payload struct {
|
||||
|
||||
@@ -93,7 +93,7 @@ func TestSAMLSettings(t *testing.T) {
|
||||
RegisterNewSamlInterface(nil)
|
||||
}
|
||||
|
||||
th := SetupEnterprise(t).InitBasic()
|
||||
th := SetupEnterprise(t)
|
||||
defer th.TearDown()
|
||||
|
||||
if tc.useNewSAMLLibrary {
|
||||
|
||||
@@ -44,8 +44,7 @@ func TestReactionsOfPost(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestExportUserNotifyProps(t *testing.T) {
|
||||
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
userNotifyProps := model.StringMap{
|
||||
@@ -113,7 +112,7 @@ func TestExportUserChannels(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDirCreationForEmoji(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
pathToDir := th.App.createDirForEmoji("test.json", "exported_emoji_test")
|
||||
@@ -123,11 +122,11 @@ func TestDirCreationForEmoji(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCopyEmojiImages(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
emoji := &model.Emoji{
|
||||
Id: th.BasicUser.Id,
|
||||
Id: model.NewId(),
|
||||
}
|
||||
|
||||
// Creating a dir named `exported_emoji_test` in the root of the repo
|
||||
|
||||
@@ -141,7 +141,7 @@ func TestOAuthDeleteApp(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAuthorizeOAuthUser(t *testing.T) {
|
||||
setup := func(enable, tokenEndpoint, userEndpoint bool, serverURL string) *TestHelper {
|
||||
setup := func(t *testing.T, enable, tokenEndpoint, userEndpoint bool, serverURL string) *TestHelper {
|
||||
th := Setup(t)
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
@@ -188,7 +188,7 @@ func TestAuthorizeOAuthUser(t *testing.T) {
|
||||
}
|
||||
|
||||
t.Run("not enabled", func(t *testing.T) {
|
||||
th := setup(false, true, true, "")
|
||||
th := setup(t, false, true, true, "")
|
||||
defer th.TearDown()
|
||||
|
||||
_, _, _, err := th.App.AuthorizeOAuthUser(nil, nil, model.SERVICE_GITLAB, "", "", "")
|
||||
@@ -197,7 +197,7 @@ func TestAuthorizeOAuthUser(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("with an improperly encoded state", func(t *testing.T) {
|
||||
th := setup(true, true, true, "")
|
||||
th := setup(t, true, true, true, "")
|
||||
defer th.TearDown()
|
||||
|
||||
state := "!"
|
||||
@@ -208,7 +208,7 @@ func TestAuthorizeOAuthUser(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("without a stored token", func(t *testing.T) {
|
||||
th := setup(true, true, true, "")
|
||||
th := setup(t, true, true, true, "")
|
||||
defer th.TearDown()
|
||||
|
||||
state := base64.StdEncoding.EncodeToString([]byte(model.MapToJson(map[string]string{
|
||||
@@ -222,7 +222,7 @@ func TestAuthorizeOAuthUser(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("with a stored token of the wrong type", func(t *testing.T) {
|
||||
th := setup(true, true, true, "")
|
||||
th := setup(t, true, true, true, "")
|
||||
defer th.TearDown()
|
||||
|
||||
token := model.NewToken("invalid", "")
|
||||
@@ -237,7 +237,7 @@ func TestAuthorizeOAuthUser(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("with email missing when changing login types", func(t *testing.T) {
|
||||
th := setup(true, true, true, "")
|
||||
th := setup(t, true, true, true, "")
|
||||
defer th.TearDown()
|
||||
|
||||
email := ""
|
||||
@@ -259,7 +259,7 @@ func TestAuthorizeOAuthUser(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("without an OAuth cookie", func(t *testing.T) {
|
||||
th := setup(true, true, true, "")
|
||||
th := setup(t, true, true, true, "")
|
||||
defer th.TearDown()
|
||||
|
||||
cookie := model.NewId()
|
||||
@@ -272,7 +272,7 @@ func TestAuthorizeOAuthUser(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("with an invalid token", func(t *testing.T) {
|
||||
th := setup(true, true, true, "")
|
||||
th := setup(t, true, true, true, "")
|
||||
defer th.TearDown()
|
||||
|
||||
cookie := model.NewId()
|
||||
@@ -289,7 +289,7 @@ func TestAuthorizeOAuthUser(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("with an incorrect token endpoint", func(t *testing.T) {
|
||||
th := setup(true, false, true, "")
|
||||
th := setup(t, true, false, true, "")
|
||||
defer th.TearDown()
|
||||
|
||||
cookie := model.NewId()
|
||||
@@ -307,7 +307,7 @@ func TestAuthorizeOAuthUser(t *testing.T) {
|
||||
}))
|
||||
defer server.Close()
|
||||
|
||||
th := setup(true, true, true, server.URL)
|
||||
th := setup(t, true, true, true, server.URL)
|
||||
defer th.TearDown()
|
||||
|
||||
cookie := model.NewId()
|
||||
@@ -326,7 +326,7 @@ func TestAuthorizeOAuthUser(t *testing.T) {
|
||||
}))
|
||||
defer server.Close()
|
||||
|
||||
th := setup(true, true, true, server.URL)
|
||||
th := setup(t, true, true, true, server.URL)
|
||||
defer th.TearDown()
|
||||
|
||||
cookie := model.NewId()
|
||||
@@ -348,7 +348,7 @@ func TestAuthorizeOAuthUser(t *testing.T) {
|
||||
}))
|
||||
defer server.Close()
|
||||
|
||||
th := setup(true, true, true, server.URL)
|
||||
th := setup(t, true, true, true, server.URL)
|
||||
defer th.TearDown()
|
||||
|
||||
cookie := model.NewId()
|
||||
@@ -369,7 +369,7 @@ func TestAuthorizeOAuthUser(t *testing.T) {
|
||||
}))
|
||||
defer server.Close()
|
||||
|
||||
th := setup(true, true, true, server.URL)
|
||||
th := setup(t, true, true, true, server.URL)
|
||||
defer th.TearDown()
|
||||
|
||||
cookie := model.NewId()
|
||||
@@ -390,7 +390,7 @@ func TestAuthorizeOAuthUser(t *testing.T) {
|
||||
}))
|
||||
defer server.Close()
|
||||
|
||||
th := setup(true, true, false, server.URL)
|
||||
th := setup(t, true, true, false, server.URL)
|
||||
defer th.TearDown()
|
||||
|
||||
cookie := model.NewId()
|
||||
@@ -418,7 +418,7 @@ func TestAuthorizeOAuthUser(t *testing.T) {
|
||||
}))
|
||||
defer server.Close()
|
||||
|
||||
th := setup(true, true, true, server.URL)
|
||||
th := setup(t, true, true, true, server.URL)
|
||||
defer th.TearDown()
|
||||
|
||||
cookie := model.NewId()
|
||||
@@ -447,7 +447,7 @@ func TestAuthorizeOAuthUser(t *testing.T) {
|
||||
}))
|
||||
defer server.Close()
|
||||
|
||||
th := setup(true, true, true, server.URL)
|
||||
th := setup(t, true, true, true, server.URL)
|
||||
defer th.TearDown()
|
||||
|
||||
cookie := model.NewId()
|
||||
@@ -487,7 +487,7 @@ func TestAuthorizeOAuthUser(t *testing.T) {
|
||||
}))
|
||||
defer server.Close()
|
||||
|
||||
th := setup(true, true, true, server.URL)
|
||||
th := setup(t, true, true, true, server.URL)
|
||||
defer th.TearDown()
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
|
||||
@@ -100,7 +100,7 @@ func setupPluginApiTest(t *testing.T, pluginCode string, pluginManifest string,
|
||||
}
|
||||
|
||||
func TestPublicFilesPathConfiguration(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
pluginID := "com.mattermost.sample"
|
||||
@@ -351,7 +351,7 @@ func TestPluginAPIGetFile(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPluginAPISavePluginConfig(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
manifest := &model.Manifest{
|
||||
@@ -394,7 +394,7 @@ func TestPluginAPISavePluginConfig(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPluginAPIGetPluginConfig(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
manifest := &model.Manifest{
|
||||
@@ -425,7 +425,7 @@ func TestPluginAPIGetPluginConfig(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPluginAPILoadPluginConfiguration(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
var pluginJson map[string]interface{}
|
||||
@@ -461,7 +461,7 @@ func TestPluginAPILoadPluginConfiguration(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPluginAPILoadPluginConfigurationDefaults(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
var pluginJson map[string]interface{}
|
||||
@@ -501,7 +501,7 @@ func TestPluginAPILoadPluginConfigurationDefaults(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPluginAPIGetPlugins(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
api := th.SetupPluginAPI()
|
||||
|
||||
@@ -559,7 +559,7 @@ func TestPluginAPIGetPlugins(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPluginAPIInstallPlugin(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
api := th.SetupPluginAPI()
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ import (
|
||||
)
|
||||
|
||||
func TestPluginPublicKeys(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
path, _ := fileutils.FindDir("tests")
|
||||
|
||||
@@ -99,7 +99,7 @@ func TestPreparePostForClient(t *testing.T) {
|
||||
serverURL = server.URL
|
||||
defer server.Close()
|
||||
|
||||
setup := func() *TestHelper {
|
||||
setup := func(t *testing.T) *TestHelper {
|
||||
th := Setup(t).InitBasic()
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
@@ -112,7 +112,7 @@ func TestPreparePostForClient(t *testing.T) {
|
||||
}
|
||||
|
||||
t.Run("no metadata needed", func(t *testing.T) {
|
||||
th := setup()
|
||||
th := setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
message := model.NewId()
|
||||
@@ -141,7 +141,7 @@ func TestPreparePostForClient(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("metadata already set", func(t *testing.T) {
|
||||
th := setup()
|
||||
th := setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
post := th.CreatePost(th.BasicChannel)
|
||||
@@ -153,7 +153,7 @@ func TestPreparePostForClient(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("reactions", func(t *testing.T) {
|
||||
th := setup()
|
||||
th := setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
post := th.CreatePost(th.BasicChannel)
|
||||
@@ -171,7 +171,7 @@ func TestPreparePostForClient(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("files", func(t *testing.T) {
|
||||
th := setup()
|
||||
th := setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
fileInfo, err := th.App.DoUploadFile(time.Now(), th.BasicTeam.Id, th.BasicChannel.Id, th.BasicUser.Id, "test.txt", []byte("test"))
|
||||
@@ -192,7 +192,7 @@ func TestPreparePostForClient(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("emojis without custom emojis enabled", func(t *testing.T) {
|
||||
th := setup()
|
||||
th := setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
@@ -233,7 +233,7 @@ func TestPreparePostForClient(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("emojis with custom emojis enabled", func(t *testing.T) {
|
||||
th := setup()
|
||||
th := setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
@@ -278,7 +278,7 @@ func TestPreparePostForClient(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("emojis overriding profile icon", func(t *testing.T) {
|
||||
th := setup()
|
||||
th := setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
prepare := func(override bool, url, emoji string) *model.Post {
|
||||
@@ -329,7 +329,7 @@ func TestPreparePostForClient(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("markdown image dimensions", func(t *testing.T) {
|
||||
th := setup()
|
||||
th := setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
post, err := th.App.CreatePost(&model.Post{
|
||||
@@ -358,21 +358,21 @@ func TestPreparePostForClient(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("proxy linked images", func(t *testing.T) {
|
||||
th := setup()
|
||||
th := setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
testProxyLinkedImage(t, th, false)
|
||||
})
|
||||
|
||||
t.Run("proxy opengraph images", func(t *testing.T) {
|
||||
th := setup()
|
||||
th := setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
testProxyOpenGraphImage(t, th, false)
|
||||
})
|
||||
|
||||
t.Run("image embed", func(t *testing.T) {
|
||||
th := setup()
|
||||
th := setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
post, err := th.App.CreatePost(&model.Post{
|
||||
@@ -408,7 +408,7 @@ func TestPreparePostForClient(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("opengraph embed", func(t *testing.T) {
|
||||
th := setup()
|
||||
th := setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
post, err := th.App.CreatePost(&model.Post{
|
||||
@@ -445,7 +445,7 @@ func TestPreparePostForClient(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("message attachment embed", func(t *testing.T) {
|
||||
th := setup()
|
||||
th := setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
post, err := th.App.CreatePost(&model.Post{
|
||||
@@ -483,7 +483,7 @@ func TestPreparePostForClient(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("no metadata for deleted posts", func(t *testing.T) {
|
||||
th := setup()
|
||||
th := setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
fileInfo, err := th.App.DoUploadFile(time.Now(), th.BasicTeam.Id, th.BasicChannel.Id, th.BasicUser.Id, "test.txt", []byte("test"))
|
||||
@@ -514,7 +514,7 @@ func TestPreparePostForClient(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPreparePostForClientWithImageProxy(t *testing.T) {
|
||||
setup := func() *TestHelper {
|
||||
setup := func(t *testing.T) *TestHelper {
|
||||
th := Setup(t).InitBasic()
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
@@ -531,14 +531,14 @@ func TestPreparePostForClientWithImageProxy(t *testing.T) {
|
||||
}
|
||||
|
||||
t.Run("proxy linked images", func(t *testing.T) {
|
||||
th := setup()
|
||||
th := setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
testProxyLinkedImage(t, th, true)
|
||||
})
|
||||
|
||||
t.Run("proxy opengraph images", func(t *testing.T) {
|
||||
th := setup()
|
||||
th := setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
testProxyOpenGraphImage(t, th, true)
|
||||
@@ -1489,7 +1489,7 @@ func TestGetImagesInMessageAttachments(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetLinkMetadata(t *testing.T) {
|
||||
setup := func() *TestHelper {
|
||||
setup := func(t *testing.T) *TestHelper {
|
||||
th := Setup(t).InitBasic()
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
@@ -1561,7 +1561,7 @@ func TestGetLinkMetadata(t *testing.T) {
|
||||
defer server.Close()
|
||||
|
||||
t.Run("in-memory cache", func(t *testing.T) {
|
||||
th := setup()
|
||||
th := setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
requestURL := server.URL + "/cached"
|
||||
@@ -1634,7 +1634,7 @@ func TestGetLinkMetadata(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("database cache", func(t *testing.T) {
|
||||
th := setup()
|
||||
th := setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
requestURL := server.URL
|
||||
@@ -1715,7 +1715,7 @@ func TestGetLinkMetadata(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("should get data from remote source", func(t *testing.T) {
|
||||
th := setup()
|
||||
th := setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
requestURL := server.URL + "/opengraph?title=Remote&name=" + t.Name()
|
||||
@@ -1735,7 +1735,7 @@ func TestGetLinkMetadata(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("should cache OpenGraph results", func(t *testing.T) {
|
||||
th := setup()
|
||||
th := setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
requestURL := server.URL + "/opengraph?title=Remote&name=" + t.Name()
|
||||
@@ -1763,7 +1763,7 @@ func TestGetLinkMetadata(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("should cache image results", func(t *testing.T) {
|
||||
th := setup()
|
||||
th := setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
requestURL := server.URL + "/image?height=300&width=400&name=" + t.Name()
|
||||
@@ -1791,7 +1791,7 @@ func TestGetLinkMetadata(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("should cache general errors", func(t *testing.T) {
|
||||
th := setup()
|
||||
th := setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
requestURL := server.URL + "/error"
|
||||
@@ -1821,7 +1821,7 @@ func TestGetLinkMetadata(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("should cache invalid URL errors", func(t *testing.T) {
|
||||
th := setup()
|
||||
th := setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
requestURL := "http://notarealdomainthatactuallyexists.ca/?name=" + t.Name()
|
||||
@@ -1851,7 +1851,7 @@ func TestGetLinkMetadata(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("should cache timeout errors", func(t *testing.T) {
|
||||
th := setup()
|
||||
th := setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
@@ -1886,7 +1886,7 @@ func TestGetLinkMetadata(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("should cache database results in memory", func(t *testing.T) {
|
||||
th := setup()
|
||||
th := setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
requestURL := server.URL + "/image?height=300&width=400&name=" + t.Name()
|
||||
@@ -1914,7 +1914,7 @@ func TestGetLinkMetadata(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("should reject non-html, non-image response", func(t *testing.T) {
|
||||
th := setup()
|
||||
th := setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
requestURL := server.URL + "/json?name=" + t.Name()
|
||||
@@ -1927,7 +1927,7 @@ func TestGetLinkMetadata(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("should check in-memory cache for new post", func(t *testing.T) {
|
||||
th := setup()
|
||||
th := setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
requestURL := server.URL + "/error?name=" + t.Name()
|
||||
@@ -1942,7 +1942,7 @@ func TestGetLinkMetadata(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("should skip database cache for new post", func(t *testing.T) {
|
||||
th := setup()
|
||||
th := setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
requestURL := server.URL + "/error?name=" + t.Name()
|
||||
@@ -1957,7 +1957,7 @@ func TestGetLinkMetadata(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("should resolve relative URL", func(t *testing.T) {
|
||||
th := setup()
|
||||
th := setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
// Fake the SiteURL to have the relative URL resolve to the external server
|
||||
@@ -1980,7 +1980,7 @@ func TestGetLinkMetadata(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("should error on local addresses other than the image proxy", func(t *testing.T) {
|
||||
th := setup()
|
||||
th := setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
// Disable AllowedUntrustedInternalConnections since it's turned on for the previous tests
|
||||
@@ -2019,7 +2019,7 @@ func TestGetLinkMetadata(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("should prefer images for mixed content", func(t *testing.T) {
|
||||
th := setup()
|
||||
th := setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
requestURL := server.URL + "/mixed?name=" + t.Name()
|
||||
|
||||
@@ -445,7 +445,7 @@ func TestPostChannelMentions(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestImageProxy(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
|
||||
Ссылка в новой задаче
Block a user