Fixed errcheck issues in server/channels/app/file_bench_test.go (#29003)

Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
Arya Khochare
2025-04-11 15:42:59 +05:30
коммит произвёл GitHub
родитель 748f8227e3
Коммит 2e2782e4bf
2 изменённых файлов: 23 добавлений и 15 удалений

Просмотреть файл

@@ -92,7 +92,6 @@ issues:
channels/app/brand.go|\ channels/app/brand.go|\
channels/app/config_test.go|\ channels/app/config_test.go|\
channels/app/file.go|\ channels/app/file.go|\
channels/app/file_bench_test.go|\
channels/app/file_test.go|\ channels/app/file_test.go|\
channels/app/helper_test.go|\ channels/app/helper_test.go|\
channels/app/import_functions.go|\ channels/app/import_functions.go|\

Просмотреть файл

@@ -14,6 +14,7 @@ import (
"time" "time"
"github.com/mattermost/mattermost/server/public/model" "github.com/mattermost/mattermost/server/public/model"
"github.com/stretchr/testify/require"
) )
var randomJPEG []byte var randomJPEG []byte
@@ -82,13 +83,13 @@ func BenchmarkUploadFile(b *testing.B) {
{ {
title: "raw-ish DoUploadFile", title: "raw-ish DoUploadFile",
f: func(b *testing.B, n int, data []byte, ext string) { f: func(b *testing.B, n int, data []byte, ext string) {
info1, err := th.App.DoUploadFile(th.Context, time.Now(), teamID, channelID, info1, appErr := th.App.DoUploadFile(th.Context, time.Now(), teamID, channelID,
userID, fmt.Sprintf("BenchmarkDoUploadFile-%d%s", n, ext), data, true) userID, fmt.Sprintf("BenchmarkDoUploadFile-%d%s", n, ext), data, true)
if err != nil { require.Nil(b, appErr)
b.Fatal(err) err := th.App.Srv().Store().FileInfo().PermanentDelete(th.Context, info1.Id)
} require.NoError(b, err)
th.App.Srv().Store().FileInfo().PermanentDelete(th.Context, info1.Id) appErr = th.App.RemoveFile(info1.Path)
th.App.RemoveFile(info1.Path) require.Nil(b, appErr)
}, },
}, },
{ {
@@ -105,8 +106,10 @@ func BenchmarkUploadFile(b *testing.B) {
if aerr != nil { if aerr != nil {
b.Fatal(aerr) b.Fatal(aerr)
} }
th.App.Srv().Store().FileInfo().PermanentDelete(th.Context, info.Id) err := th.App.Srv().Store().FileInfo().PermanentDelete(th.Context, info.Id)
th.App.RemoveFile(info.Path) require.NoError(b, err)
appErr := th.App.RemoveFile(info.Path)
require.Nil(b, appErr)
}, },
}, },
{ {
@@ -123,8 +126,10 @@ func BenchmarkUploadFile(b *testing.B) {
if aerr != nil { if aerr != nil {
b.Fatal(aerr) b.Fatal(aerr)
} }
th.App.Srv().Store().FileInfo().PermanentDelete(th.Context, info.Id) err := th.App.Srv().Store().FileInfo().PermanentDelete(th.Context, info.Id)
th.App.RemoveFile(info.Path) require.NoError(b, err)
appErr := th.App.RemoveFile(info.Path)
require.Nil(b, appErr)
}, },
}, },
{ {
@@ -140,8 +145,10 @@ func BenchmarkUploadFile(b *testing.B) {
if aerr != nil { if aerr != nil {
b.Fatal(aerr) b.Fatal(aerr)
} }
th.App.Srv().Store().FileInfo().PermanentDelete(th.Context, info.Id) err := th.App.Srv().Store().FileInfo().PermanentDelete(th.Context, info.Id)
th.App.RemoveFile(info.Path) require.NoError(b, err)
appErr := th.App.RemoveFile(info.Path)
require.Nil(b, appErr)
}, },
}, },
{ {
@@ -157,8 +164,10 @@ func BenchmarkUploadFile(b *testing.B) {
if aerr != nil { if aerr != nil {
b.Fatal(aerr) b.Fatal(aerr)
} }
th.App.Srv().Store().FileInfo().PermanentDelete(th.Context, info.Id) err := th.App.Srv().Store().FileInfo().PermanentDelete(th.Context, info.Id)
th.App.RemoveFile(info.Path) require.NoError(b, err)
appErr := th.App.RemoveFile(info.Path)
require.Nil(b, appErr)
}, },
}, },
} }