[MM-55053] Use request-specific logger in channels/app/file.go (#25037)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
45d6fb122f
Коммит
b0bf5d0765
@@ -217,7 +217,7 @@ func TestParseOldFilenames(t *testing.T) {
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.description, func(tt *testing.T) {
|
||||
result := parseOldFilenames(test.filenames, test.channelID, test.userID)
|
||||
result := parseOldFilenames(th.Context, test.filenames, test.channelID, test.userID)
|
||||
require.Equal(tt, result, test.expected)
|
||||
})
|
||||
}
|
||||
@@ -230,7 +230,7 @@ func TestGetInfoForFilename(t *testing.T) {
|
||||
post := th.BasicPost
|
||||
teamID := th.BasicTeam.Id
|
||||
|
||||
info := th.App.getInfoForFilename(post, teamID, post.ChannelId, post.UserId, "someid", "somefile.png")
|
||||
info := th.App.getInfoForFilename(th.Context, post, teamID, post.ChannelId, post.UserId, "someid", "somefile.png")
|
||||
assert.Nil(t, info, "Test non-existent file")
|
||||
}
|
||||
|
||||
@@ -238,13 +238,13 @@ func TestFindTeamIdForFilename(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
teamID := th.App.findTeamIdForFilename(th.BasicPost, "someid", "somefile.png")
|
||||
teamID := th.App.findTeamIdForFilename(th.Context, th.BasicPost, "someid", "somefile.png")
|
||||
assert.Equal(t, th.BasicTeam.Id, teamID)
|
||||
|
||||
_, err := th.App.CreateTeamWithUser(th.Context, &model.Team{Email: th.BasicUser.Email, Name: "zz" + model.NewId(), DisplayName: "Joram's Test Team", Type: model.TeamOpen}, th.BasicUser.Id)
|
||||
require.Nil(t, err)
|
||||
|
||||
teamID = th.App.findTeamIdForFilename(th.BasicPost, "someid", "somefile.png")
|
||||
teamID = th.App.findTeamIdForFilename(th.Context, th.BasicPost, "someid", "somefile.png")
|
||||
assert.Equal(t, "", teamID)
|
||||
}
|
||||
|
||||
@@ -253,11 +253,11 @@ func TestMigrateFilenamesToFileInfos(t *testing.T) {
|
||||
defer th.TearDown()
|
||||
|
||||
post := th.BasicPost
|
||||
infos := th.App.MigrateFilenamesToFileInfos(post)
|
||||
infos := th.App.MigrateFilenamesToFileInfos(th.Context, post)
|
||||
assert.Equal(t, 0, len(infos))
|
||||
|
||||
post.Filenames = []string{fmt.Sprintf("/%v/%v/%v/blargh.png", th.BasicChannel.Id, th.BasicUser.Id, "someid")}
|
||||
infos = th.App.MigrateFilenamesToFileInfos(post)
|
||||
infos = th.App.MigrateFilenamesToFileInfos(th.Context, post)
|
||||
assert.Equal(t, 0, len(infos))
|
||||
|
||||
path, _ := fileutils.FindDir("tests")
|
||||
@@ -272,13 +272,13 @@ func TestMigrateFilenamesToFileInfos(t *testing.T) {
|
||||
rpost, err := th.App.CreatePost(th.Context, &model.Post{UserId: th.BasicUser.Id, ChannelId: th.BasicChannel.Id, Filenames: []string{fmt.Sprintf("/%v/%v/%v/test.png", th.BasicChannel.Id, th.BasicUser.Id, fileID)}}, th.BasicChannel, false, true)
|
||||
require.Nil(t, err)
|
||||
|
||||
infos = th.App.MigrateFilenamesToFileInfos(rpost)
|
||||
infos = th.App.MigrateFilenamesToFileInfos(th.Context, rpost)
|
||||
assert.Equal(t, 1, len(infos))
|
||||
|
||||
rpost, err = th.App.CreatePost(th.Context, &model.Post{UserId: th.BasicUser.Id, ChannelId: th.BasicChannel.Id, Filenames: []string{fmt.Sprintf("/%v/%v/%v/../../test.png", th.BasicChannel.Id, th.BasicUser.Id, fileID)}}, th.BasicChannel, false, true)
|
||||
require.Nil(t, err)
|
||||
|
||||
infos = th.App.MigrateFilenamesToFileInfos(rpost)
|
||||
infos = th.App.MigrateFilenamesToFileInfos(th.Context, rpost)
|
||||
assert.Equal(t, 0, len(infos))
|
||||
}
|
||||
|
||||
@@ -355,7 +355,7 @@ func TestCopyFileInfos(t *testing.T) {
|
||||
infoIds, err := th.App.CopyFileInfos(userID, []string{info1.Id})
|
||||
require.Nil(t, err)
|
||||
|
||||
info2, err := th.App.GetFileInfo(infoIds[0])
|
||||
info2, err := th.App.GetFileInfo(th.Context, infoIds[0])
|
||||
require.Nil(t, err)
|
||||
defer func() {
|
||||
th.App.Srv().Store().FileInfo().PermanentDelete(info2.Id)
|
||||
@@ -377,7 +377,7 @@ func TestGenerateThumbnailImage(t *testing.T) {
|
||||
thumbnailPath := filepath.Join(dataPath, thumbnailName)
|
||||
|
||||
// when
|
||||
th.App.generateThumbnailImage(img, "jpg", thumbnailName)
|
||||
th.App.generateThumbnailImage(th.Context, img, "jpg", thumbnailName)
|
||||
defer os.Remove(thumbnailPath)
|
||||
|
||||
// then
|
||||
|
||||
Ссылка в новой задаче
Block a user