[MM-61302] Use model.NewPointer throughout the code base (#28957)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
97c7c25820
Коммит
2424358b7d
@@ -204,9 +204,9 @@ func TestPatchBot(t *testing.T) {
|
||||
|
||||
th.TestForSystemAdminAndLocal(t, func(t *testing.T, client *model.Client4) {
|
||||
botPatch := &model.BotPatch{
|
||||
Username: sToP(GenerateTestUsername()),
|
||||
DisplayName: sToP("an updated bot"),
|
||||
Description: sToP("updated bot"),
|
||||
Username: model.NewPointer(GenerateTestUsername()),
|
||||
DisplayName: model.NewPointer("an updated bot"),
|
||||
Description: model.NewPointer("updated bot"),
|
||||
}
|
||||
patchedBot, patchResp, err2 := client.PatchBot(context.Background(), createdBot.UserId, botPatch)
|
||||
require.NoError(t, err2)
|
||||
@@ -231,9 +231,9 @@ func TestPatchBot(t *testing.T) {
|
||||
|
||||
th.TestForSystemAdminAndLocal(t, func(t *testing.T, client *model.Client4) {
|
||||
botPatch := &model.BotPatch{
|
||||
Username: sToP(GenerateTestUsername()),
|
||||
DisplayName: sToP("an updated bot"),
|
||||
Description: sToP("updated bot"),
|
||||
Username: model.NewPointer(GenerateTestUsername()),
|
||||
DisplayName: model.NewPointer("an updated bot"),
|
||||
Description: model.NewPointer("updated bot"),
|
||||
}
|
||||
patchedBot, patchResp, err := client.PatchBot(context.Background(), createdBotSystemAdmin.UserId, botPatch)
|
||||
require.NoError(t, err)
|
||||
@@ -323,9 +323,9 @@ func TestPatchBot(t *testing.T) {
|
||||
}()
|
||||
|
||||
botPatch := &model.BotPatch{
|
||||
Username: sToP(GenerateTestUsername()),
|
||||
DisplayName: sToP("an updated bot"),
|
||||
Description: sToP("updated bot"),
|
||||
Username: model.NewPointer(GenerateTestUsername()),
|
||||
DisplayName: model.NewPointer("an updated bot"),
|
||||
Description: model.NewPointer("updated bot"),
|
||||
}
|
||||
|
||||
patchedBot, resp, err := th.Client.PatchBot(context.Background(), createdBot.UserId, botPatch)
|
||||
@@ -379,9 +379,9 @@ func TestPatchBot(t *testing.T) {
|
||||
}()
|
||||
|
||||
botPatch := &model.BotPatch{
|
||||
Username: sToP(GenerateTestUsername()),
|
||||
DisplayName: sToP("an updated bot"),
|
||||
Description: sToP("updated bot"),
|
||||
Username: model.NewPointer(GenerateTestUsername()),
|
||||
DisplayName: model.NewPointer("an updated bot"),
|
||||
Description: model.NewPointer("updated bot"),
|
||||
}
|
||||
|
||||
_, _, err = th.Client.PatchBot(context.Background(), createdBot.UserId, botPatch)
|
||||
@@ -414,9 +414,9 @@ func TestPatchBot(t *testing.T) {
|
||||
}()
|
||||
|
||||
botPatch := &model.BotPatch{
|
||||
Username: sToP(GenerateTestUsername()),
|
||||
DisplayName: sToP("an updated bot"),
|
||||
Description: sToP("updated bot"),
|
||||
Username: model.NewPointer(GenerateTestUsername()),
|
||||
DisplayName: model.NewPointer("an updated bot"),
|
||||
Description: model.NewPointer("updated bot"),
|
||||
}
|
||||
|
||||
_, _, err = th.Client.PatchBot(context.Background(), createdBot.UserId, botPatch)
|
||||
@@ -449,9 +449,9 @@ func TestPatchBot(t *testing.T) {
|
||||
}()
|
||||
|
||||
botPatch := &model.BotPatch{
|
||||
Username: sToP(GenerateTestUsername()),
|
||||
DisplayName: sToP("an updated bot"),
|
||||
Description: sToP("updated bot"),
|
||||
Username: model.NewPointer(GenerateTestUsername()),
|
||||
DisplayName: model.NewPointer("an updated bot"),
|
||||
Description: model.NewPointer("updated bot"),
|
||||
}
|
||||
|
||||
patchedBot, resp, err := th.Client.PatchBot(context.Background(), createdBot.UserId, botPatch)
|
||||
@@ -491,7 +491,7 @@ func TestPatchBot(t *testing.T) {
|
||||
}()
|
||||
|
||||
botPatch := &model.BotPatch{
|
||||
Username: sToP(GenerateTestUsername()),
|
||||
Username: model.NewPointer(GenerateTestUsername()),
|
||||
}
|
||||
|
||||
patchedBot, resp, err := th.Client.PatchBot(context.Background(), createdBot.UserId, botPatch)
|
||||
@@ -1546,7 +1546,3 @@ func TestConvertBotToUser(t *testing.T) {
|
||||
CheckNotFoundStatus(t, resp)
|
||||
})
|
||||
}
|
||||
|
||||
func sToP(s string) *string {
|
||||
return &s
|
||||
}
|
||||
|
||||
@@ -273,7 +273,7 @@ func TestUpdateConfig(t *testing.T) {
|
||||
require.Equal(t, nonEmptyURL, *cfg.ServiceSettings.SiteURL)
|
||||
|
||||
// Check that the Site URL can't be cleared
|
||||
cfg.ServiceSettings.SiteURL = sToP("")
|
||||
cfg.ServiceSettings.SiteURL = model.NewPointer("")
|
||||
cfg, resp, err = th.SystemAdminClient.UpdateConfig(context.Background(), cfg)
|
||||
require.Error(t, err)
|
||||
CheckBadRequestStatus(t, resp)
|
||||
|
||||
@@ -206,9 +206,9 @@ func TestPatchBot(t *testing.T) {
|
||||
}()
|
||||
|
||||
botPatch := &model.BotPatch{
|
||||
Username: sToP("invalid username"),
|
||||
DisplayName: sToP("an updated bot"),
|
||||
Description: sToP("updated bot"),
|
||||
Username: model.NewPointer("invalid username"),
|
||||
DisplayName: model.NewPointer("an updated bot"),
|
||||
Description: model.NewPointer("updated bot"),
|
||||
}
|
||||
|
||||
_, err = th.App.PatchBot(th.Context, bot.UserId, botPatch)
|
||||
@@ -232,9 +232,9 @@ func TestPatchBot(t *testing.T) {
|
||||
}()
|
||||
|
||||
botPatch := &model.BotPatch{
|
||||
Username: sToP("username"),
|
||||
DisplayName: sToP("display name"),
|
||||
Description: sToP(strings.Repeat("x", 1025)),
|
||||
Username: model.NewPointer("username"),
|
||||
DisplayName: model.NewPointer("display name"),
|
||||
Description: model.NewPointer(strings.Repeat("x", 1025)),
|
||||
}
|
||||
|
||||
_, err = th.App.PatchBot(th.Context, bot.UserId, botPatch)
|
||||
@@ -261,9 +261,9 @@ func TestPatchBot(t *testing.T) {
|
||||
}()
|
||||
|
||||
botPatch := &model.BotPatch{
|
||||
Username: sToP("username2"),
|
||||
DisplayName: sToP("updated bot"),
|
||||
Description: sToP("an updated bot"),
|
||||
Username: model.NewPointer("username2"),
|
||||
DisplayName: model.NewPointer("updated bot"),
|
||||
Description: model.NewPointer("an updated bot"),
|
||||
}
|
||||
|
||||
patchedBot, err := th.App.PatchBot(th.Context, createdBot.UserId, botPatch)
|
||||
@@ -296,7 +296,7 @@ func TestPatchBot(t *testing.T) {
|
||||
}()
|
||||
|
||||
botPatch := &model.BotPatch{
|
||||
Username: sToP(th.BasicUser2.Username),
|
||||
Username: model.NewPointer(th.BasicUser2.Username),
|
||||
}
|
||||
|
||||
_, err = th.App.PatchBot(th.Context, bot.UserId, botPatch)
|
||||
@@ -927,7 +927,3 @@ func TestGetSystemBot(t *testing.T) {
|
||||
require.Equal(t, bot.UserId, botUser.Id)
|
||||
})
|
||||
}
|
||||
|
||||
func sToP(s string) *string {
|
||||
return &s
|
||||
}
|
||||
|
||||
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
@@ -23,22 +23,6 @@ import (
|
||||
"github.com/mattermost/mattermost/server/v8/channels/utils/fileutils"
|
||||
)
|
||||
|
||||
func ptrStr(s string) *string {
|
||||
return &s
|
||||
}
|
||||
|
||||
func ptrInt64(i int64) *int64 {
|
||||
return &i
|
||||
}
|
||||
|
||||
func ptrInt(i int) *int {
|
||||
return &i
|
||||
}
|
||||
|
||||
func ptrBool(b bool) *bool {
|
||||
return &b
|
||||
}
|
||||
|
||||
func checkPreference(t *testing.T, a *App, userID string, category string, name string, value string) {
|
||||
preferences, err := a.Srv().Store().Preference().GetCategory(userID, category)
|
||||
require.NoErrorf(t, err, "Failed to get preferences for user %v with category %v", userID, category)
|
||||
@@ -250,7 +234,7 @@ func TestImportBulkImport(t *testing.T) {
|
||||
func TestImportProcessImportDataFileVersionLine(t *testing.T) {
|
||||
data := imports.LineImportData{
|
||||
Type: "version",
|
||||
Version: ptrInt(1),
|
||||
Version: model.NewPointer(1),
|
||||
}
|
||||
version, err := processImportDataFileVersionLine(data)
|
||||
require.Nil(t, err, "Expected no error")
|
||||
|
||||
@@ -2992,7 +2992,7 @@ func TestCollapsedThreadFetch(t *testing.T) {
|
||||
Email: "success+" + id + "@simulator.amazonses.com",
|
||||
Username: "un_" + id,
|
||||
Nickname: "nn_" + id,
|
||||
AuthData: ptrStr("bobbytables"),
|
||||
AuthData: model.NewPointer("bobbytables"),
|
||||
AuthService: "saml",
|
||||
EmailVerified: true,
|
||||
})
|
||||
|
||||
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
@@ -214,13 +214,13 @@ func TestGetSubpathFromConfig(t *testing.T) {
|
||||
}{
|
||||
{
|
||||
"empty SiteURL",
|
||||
sToP(""),
|
||||
model.NewPointer(""),
|
||||
false,
|
||||
"/",
|
||||
},
|
||||
{
|
||||
"invalid SiteURL",
|
||||
sToP("cache_object:foo/bar"),
|
||||
model.NewPointer("cache_object:foo/bar"),
|
||||
true,
|
||||
"",
|
||||
},
|
||||
@@ -232,25 +232,25 @@ func TestGetSubpathFromConfig(t *testing.T) {
|
||||
},
|
||||
{
|
||||
"no trailing slash",
|
||||
sToP("http://localhost:8065"),
|
||||
model.NewPointer("http://localhost:8065"),
|
||||
false,
|
||||
"/",
|
||||
},
|
||||
{
|
||||
"trailing slash",
|
||||
sToP("http://localhost:8065/"),
|
||||
model.NewPointer("http://localhost:8065/"),
|
||||
false,
|
||||
"/",
|
||||
},
|
||||
{
|
||||
"subpath, no trailing slash",
|
||||
sToP("http://localhost:8065/subpath"),
|
||||
model.NewPointer("http://localhost:8065/subpath"),
|
||||
false,
|
||||
"/subpath",
|
||||
},
|
||||
{
|
||||
"trailing slash",
|
||||
sToP("http://localhost:8065/subpath/"),
|
||||
model.NewPointer("http://localhost:8065/subpath/"),
|
||||
false,
|
||||
"/subpath",
|
||||
},
|
||||
@@ -276,10 +276,6 @@ func TestGetSubpathFromConfig(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func sToP(s string) *string {
|
||||
return &s
|
||||
}
|
||||
|
||||
const contentSecurityPolicyNotFoundHTML = `<!DOCTYPE html> <html lang=en> <head> <meta charset=utf-8> <meta http-equiv=Content-Security-Policy content="script-src 'self' cdn.rudderlabs.com/ js.stripe.com/v3"> <meta http-equiv=X-UA-Compatible content="IE=edge"> <meta name=viewport content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=0"> <meta name=robots content="noindex, nofollow"> <meta name=referrer content=no-referrer> <title>Mattermost</title> <meta name=apple-mobile-web-app-capable content=yes> <meta name=apple-mobile-web-app-status-bar-style content=default> <meta name=mobile-web-app-capable content=yes> <meta name=apple-mobile-web-app-title content=Mattermost> <meta name=application-name content=Mattermost> <meta name=format-detection content="telephone=no"> <link rel=apple-touch-icon sizes=57x57 href=/static/files/78b7e73b41b8731ce2c41c870ecc8886.png> <link rel=apple-touch-icon sizes=60x60 href=/static/files/51d00ffd13afb6d74fd8f6dfdeef768a.png> <link rel=apple-touch-icon sizes=72x72 href=/static/files/23645596f8f78f017bd4d457abb855c4.png> <link rel=apple-touch-icon sizes=76x76 href=/static/files/26e9d72f472663a00b4b206149459fab.png> <link rel=apple-touch-icon sizes=144x144 href=/static/files/7bd91659bf3fc8c68fcd45fc1db9c630.png> <link rel=apple-touch-icon sizes=120x120 href=/static/files/fa69ffe11eb334aaef5aece8d848ca62.png> <link rel=apple-touch-icon sizes=152x152 href=/static/files/f046777feb6ab12fc43b8f9908b1db35.png> <link rel=icon type=image/png sizes=16x16 href=/static/files/02b96247d275680adaaabf01c71c571d.png> <link rel=icon type=image/png sizes=32x32 href=/static/files/1d9020f201a6762421cab8d30624fdd8.png> <link rel=icon type=image/png sizes=96x96 href=/static/files/fe23af39ae98d77dc26ae8586565970f.png> <link rel=icon type=image/png sizes=192x192 href=/static/files/d7ff68a7675f84337cc154c3d4abe713.png> <link rel=manifest href=/static/files/a985ad72552ad069537d6eea81e719c7.json> <link rel=stylesheet class=code_theme> < <link href="/static/main.364fd054d7a6d741efc6.css" rel="stylesheet"><script type="text/javascript" src="/static/main.e49599ac425584ffead5.js"></script></head> <body class=font--open_sans> <div id=root> <div class=error-screen> <h2>Cannot connect to Mattermost</h2> <hr/> <p>We're having trouble connecting to Mattermost. If refreshing this page (Ctrl+R or Command+R) does not work, please verify that your computer is connected to the internet.</p> <br/> </div> <div class=loading-screen style=position:relative> <div class=loading__content> <div class="round round-1"></div> <div class="round round-2"></div> <div class="round round-3"></div> </div> </div> </div> <noscript> To use Mattermost, please enable JavaScript. </noscript> </body> </html>`
|
||||
|
||||
const contentSecurityPolicyNotFound2HTML = `<!DOCTYPE html> <html lang=en> <head> <meta charset=utf-8> <meta http-equiv=Content-Security-Policy content="script-src 'self' cdn.rudderlabs.com/ js.stripe.com/v3 'unsafe-eval'"> <meta http-equiv=X-UA-Compatible content="IE=edge"> <meta name=viewport content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=0"> <meta name=robots content="noindex, nofollow"> <meta name=referrer content=no-referrer> <title>Mattermost</title> <meta name=apple-mobile-web-app-capable content=yes> <meta name=apple-mobile-web-app-status-bar-style content=default> <meta name=mobile-web-app-capable content=yes> <meta name=apple-mobile-web-app-title content=Mattermost> <meta name=application-name content=Mattermost> <meta name=format-detection content="telephone=no"> <link rel=apple-touch-icon sizes=57x57 href=/static/files/78b7e73b41b8731ce2c41c870ecc8886.png> <link rel=apple-touch-icon sizes=60x60 href=/static/files/51d00ffd13afb6d74fd8f6dfdeef768a.png> <link rel=apple-touch-icon sizes=72x72 href=/static/files/23645596f8f78f017bd4d457abb855c4.png> <link rel=apple-touch-icon sizes=76x76 href=/static/files/26e9d72f472663a00b4b206149459fab.png> <link rel=apple-touch-icon sizes=144x144 href=/static/files/7bd91659bf3fc8c68fcd45fc1db9c630.png> <link rel=apple-touch-icon sizes=120x120 href=/static/files/fa69ffe11eb334aaef5aece8d848ca62.png> <link rel=apple-touch-icon sizes=152x152 href=/static/files/f046777feb6ab12fc43b8f9908b1db35.png> <link rel=icon type=image/png sizes=16x16 href=/static/files/02b96247d275680adaaabf01c71c571d.png> <link rel=icon type=image/png sizes=32x32 href=/static/files/1d9020f201a6762421cab8d30624fdd8.png> <link rel=icon type=image/png sizes=96x96 href=/static/files/fe23af39ae98d77dc26ae8586565970f.png> <link rel=icon type=image/png sizes=192x192 href=/static/files/d7ff68a7675f84337cc154c3d4abe713.png> <link rel=manifest href=/static/files/a985ad72552ad069537d6eea81e719c7.json> <link rel=stylesheet class=code_theme> <link href="/static/main.364fd054d7a6d741efc6.css" rel="stylesheet"><script type="text/javascript" src="/static/main.e49599ac425584ffead5.js"></script></head> <body class=font--open_sans> <div id=root> <div class=error-screen> <h2>Cannot connect to Mattermost</h2> <hr/> <p>We're having trouble connecting to Mattermost. If refreshing this page (Ctrl+R or Command+R) does not work, please verify that your computer is connected to the internet.</p> <br/> </div> <div class=loading-screen style=position:relative> <div class=loading__content> <div class="round round-1"></div> <div class="round round-2"></div> <div class="round round-3"></div> </div> </div> </div> <noscript> To use Mattermost, please enable JavaScript. </noscript> </body> </html>`
|
||||
|
||||
@@ -24,7 +24,7 @@ type mockMarketplaceMeteringClient struct {
|
||||
|
||||
func (m *mockMarketplaceMeteringClient) MeterUsage(input *marketplacemetering.MeterUsageInput) (*marketplacemetering.MeterUsageOutput, error) {
|
||||
return &marketplacemetering.MeterUsageOutput{
|
||||
MeteringRecordId: String("1"),
|
||||
MeteringRecordId: model.NewPointer("1"),
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -36,9 +36,6 @@ func (m *mockMarketplaceMeteringClientWithError) MeterUsage(input *marketplaceme
|
||||
return nil, errors.New("error")
|
||||
}
|
||||
|
||||
func String(i string) *string {
|
||||
return &i
|
||||
}
|
||||
func TestAwsMeterUsage(t *testing.T) {
|
||||
startTime := time.Now()
|
||||
endTime := time.Now()
|
||||
|
||||
@@ -368,10 +368,6 @@ func TestBotEtag(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func sToP(s string) *string {
|
||||
return &s
|
||||
}
|
||||
|
||||
func TestBotPatch(t *testing.T) {
|
||||
userId1 := NewId()
|
||||
creatorId1 := NewId()
|
||||
@@ -422,9 +418,9 @@ func TestBotPatch(t *testing.T) {
|
||||
DeleteAt: 4,
|
||||
},
|
||||
&BotPatch{
|
||||
Username: sToP("new_username"),
|
||||
Username: NewPointer("new_username"),
|
||||
DisplayName: nil,
|
||||
Description: sToP("new description"),
|
||||
Description: NewPointer("new description"),
|
||||
},
|
||||
&Bot{
|
||||
UserId: userId1,
|
||||
@@ -452,9 +448,9 @@ func TestBotPatch(t *testing.T) {
|
||||
DeleteAt: 4,
|
||||
},
|
||||
&BotPatch{
|
||||
Username: sToP("new_username"),
|
||||
DisplayName: sToP("new display name"),
|
||||
Description: sToP("new description"),
|
||||
Username: NewPointer("new_username"),
|
||||
DisplayName: NewPointer("new display name"),
|
||||
Description: NewPointer("new description"),
|
||||
},
|
||||
&Bot{
|
||||
UserId: userId1,
|
||||
|
||||
Ссылка в новой задаче
Block a user