diff options
| author | 2025-05-22 12:26:11 +0200 | |
|---|---|---|
| committer | 2025-05-22 12:26:11 +0200 | |
| commit | d5c9c4adc167cdb05e73f5105702cf340293e61c (patch) | |
| tree | 1d21fe376099864900837eba675a965517f98e5d /internal/api/fileserver/servefile_test.go | |
| parent | [feature] Allow exposing allows, implement `/api/v1/domain_blocks` and `/api/... (diff) | |
| download | gotosocial-d5c9c4adc167cdb05e73f5105702cf340293e61c.tar.xz | |
[chore] Upgrade to Go 1.24 (#4187)
* Set `go.mod` to 1.24 now that it's been out for 3 months.
* Update all the test to use `testing.T.Context()`.
Reviewed-on: https://codeberg.org/superseriousbusiness/gotosocial/pulls/4187
Co-authored-by: Daenney <git@noreply.sourcery.dny.nu>
Co-committed-by: Daenney <git@noreply.sourcery.dny.nu>
Diffstat (limited to 'internal/api/fileserver/servefile_test.go')
| -rw-r--r-- | internal/api/fileserver/servefile_test.go | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/internal/api/fileserver/servefile_test.go b/internal/api/fileserver/servefile_test.go index cfaa73515..e07c204eb 100644 --- a/internal/api/fileserver/servefile_test.go +++ b/internal/api/fileserver/servefile_test.go @@ -18,7 +18,6 @@ package fileserver_test import ( - "context" "io" "net/http" "net/http/httptest" @@ -74,7 +73,7 @@ func (suite *ServeFileTestSuite) GetFile( // UncacheAttachment is a convenience function that uncaches the targetAttachment by // removing its associated files from storage, and updating the database. func (suite *ServeFileTestSuite) UncacheAttachment(targetAttachment *gtsmodel.MediaAttachment) { - ctx := context.Background() + ctx := suite.T().Context() cached := false targetAttachment.Cached = &cached @@ -93,7 +92,7 @@ func (suite *ServeFileTestSuite) UncacheAttachment(targetAttachment *gtsmodel.Me func (suite *ServeFileTestSuite) TestServeOriginalLocalFileOK() { targetAttachment := >smodel.MediaAttachment{} *targetAttachment = *suite.testAttachments["admin_account_status_1_attachment_1"] - fileInStorage, err := suite.storage.Get(context.Background(), targetAttachment.File.Path) + fileInStorage, err := suite.storage.Get(suite.T().Context(), targetAttachment.File.Path) if err != nil { suite.FailNow(err.Error()) } @@ -113,7 +112,7 @@ func (suite *ServeFileTestSuite) TestServeOriginalLocalFileOK() { func (suite *ServeFileTestSuite) TestServeSmallLocalFileOK() { targetAttachment := >smodel.MediaAttachment{} *targetAttachment = *suite.testAttachments["admin_account_status_1_attachment_1"] - fileInStorage, err := suite.storage.Get(context.Background(), targetAttachment.Thumbnail.Path) + fileInStorage, err := suite.storage.Get(suite.T().Context(), targetAttachment.Thumbnail.Path) if err != nil { suite.FailNow(err.Error()) } @@ -133,7 +132,7 @@ func (suite *ServeFileTestSuite) TestServeSmallLocalFileOK() { func (suite *ServeFileTestSuite) TestServeOriginalRemoteFileOK() { targetAttachment := >smodel.MediaAttachment{} *targetAttachment = *suite.testAttachments["remote_account_1_status_1_attachment_1"] - fileInStorage, err := suite.storage.Get(context.Background(), targetAttachment.File.Path) + fileInStorage, err := suite.storage.Get(suite.T().Context(), targetAttachment.File.Path) if err != nil { suite.FailNow(err.Error()) } @@ -153,7 +152,7 @@ func (suite *ServeFileTestSuite) TestServeOriginalRemoteFileOK() { func (suite *ServeFileTestSuite) TestServeSmallRemoteFileOK() { targetAttachment := >smodel.MediaAttachment{} *targetAttachment = *suite.testAttachments["remote_account_1_status_1_attachment_1"] - fileInStorage, err := suite.storage.Get(context.Background(), targetAttachment.Thumbnail.Path) + fileInStorage, err := suite.storage.Get(suite.T().Context(), targetAttachment.Thumbnail.Path) if err != nil { suite.FailNow(err.Error()) } @@ -173,7 +172,7 @@ func (suite *ServeFileTestSuite) TestServeSmallRemoteFileOK() { func (suite *ServeFileTestSuite) TestServeOriginalRemoteFileRecache() { targetAttachment := >smodel.MediaAttachment{} *targetAttachment = *suite.testAttachments["remote_account_1_status_1_attachment_1"] - fileInStorage, err := suite.storage.Get(context.Background(), targetAttachment.File.Path) + fileInStorage, err := suite.storage.Get(suite.T().Context(), targetAttachment.File.Path) if err != nil { suite.FailNow(err.Error()) } @@ -196,7 +195,7 @@ func (suite *ServeFileTestSuite) TestServeOriginalRemoteFileRecache() { func (suite *ServeFileTestSuite) TestServeSmallRemoteFileRecache() { targetAttachment := >smodel.MediaAttachment{} *targetAttachment = *suite.testAttachments["remote_account_1_status_1_attachment_1"] - fileInStorage, err := suite.storage.Get(context.Background(), targetAttachment.Thumbnail.Path) + fileInStorage, err := suite.storage.Get(suite.T().Context(), targetAttachment.Thumbnail.Path) if err != nil { suite.FailNow(err.Error()) } @@ -223,7 +222,7 @@ func (suite *ServeFileTestSuite) TestServeOriginalRemoteFileRecacheNotFound() { // uncache the attachment *and* set the remote URL to something that will return a 404 suite.UncacheAttachment(targetAttachment) targetAttachment.RemoteURL = "http://nothing.at.this.url/weeeeeeeee" - if err := suite.db.UpdateByID(context.Background(), targetAttachment, targetAttachment.ID, "remote_url"); err != nil { + if err := suite.db.UpdateByID(suite.T().Context(), targetAttachment, targetAttachment.ID, "remote_url"); err != nil { suite.FailNow(err.Error()) } @@ -244,7 +243,7 @@ func (suite *ServeFileTestSuite) TestServeSmallRemoteFileRecacheNotFound() { // uncache the attachment *and* set the remote URL to something that will return a 404 suite.UncacheAttachment(targetAttachment) targetAttachment.RemoteURL = "http://nothing.at.this.url/weeeeeeeee" - if err := suite.db.UpdateByID(context.Background(), targetAttachment, targetAttachment.ID, "remote_url"); err != nil { + if err := suite.db.UpdateByID(suite.T().Context(), targetAttachment, targetAttachment.ID, "remote_url"); err != nil { suite.FailNow(err.Error()) } |
