diff options
| author | 2025-05-22 12:26:11 +0200 | |
|---|---|---|
| committer | 2025-05-22 12:26:11 +0200 | |
| commit | d5c9c4adc167cdb05e73f5105702cf340293e61c (patch) | |
| tree | 1d21fe376099864900837eba675a965517f98e5d /internal/typeutils/internaltoas_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/typeutils/internaltoas_test.go')
| -rw-r--r-- | internal/typeutils/internaltoas_test.go | 53 |
1 files changed, 26 insertions, 27 deletions
diff --git a/internal/typeutils/internaltoas_test.go b/internal/typeutils/internaltoas_test.go index 5ba23a77e..ab81095fd 100644 --- a/internal/typeutils/internaltoas_test.go +++ b/internal/typeutils/internaltoas_test.go @@ -18,7 +18,6 @@ package typeutils_test import ( - "context" "encoding/json" "errors" "testing" @@ -38,7 +37,7 @@ func (suite *InternalToASTestSuite) TestAccountToAS() { testAccount := >smodel.Account{} *testAccount = *suite.testAccounts["local_account_1"] // take zork for this test - accountable, err := suite.typeconverter.AccountToAS(context.Background(), testAccount) + accountable, err := suite.typeconverter.AccountToAS(suite.T().Context(), testAccount) suite.NoError(err) ser, err := ap.Serialize(accountable) @@ -100,11 +99,11 @@ func (suite *InternalToASTestSuite) TestAccountToASBot() { // Update zork to be a bot. testAccount.ActorType = gtsmodel.AccountActorTypeApplication - if err := suite.state.DB.UpdateAccount(context.Background(), testAccount); err != nil { + if err := suite.state.DB.UpdateAccount(suite.T().Context(), testAccount); err != nil { suite.FailNow(err.Error()) } - accountable, err := suite.typeconverter.AccountToAS(context.Background(), testAccount) + accountable, err := suite.typeconverter.AccountToAS(suite.T().Context(), testAccount) suite.NoError(err) ser, err := ap.Serialize(accountable) @@ -164,7 +163,7 @@ func (suite *InternalToASTestSuite) TestAccountToASWithFields() { testAccount := >smodel.Account{} *testAccount = *suite.testAccounts["local_account_2"] - accountable, err := suite.typeconverter.AccountToAS(context.Background(), testAccount) + accountable, err := suite.typeconverter.AccountToAS(suite.T().Context(), testAccount) suite.NoError(err) ser, err := ap.Serialize(accountable) @@ -229,7 +228,7 @@ func (suite *InternalToASTestSuite) TestAccountToASAliasedAndMoved() { testAccount := >smodel.Account{} *testAccount = *suite.testAccounts["local_account_1"] // take zork for this test - ctx := context.Background() + ctx := suite.T().Context() // Suppose zork has moved account to turtle. testAccount.AlsoKnownAsURIs = []string{"http://localhost:8080/users/1happyturtle"} @@ -242,7 +241,7 @@ func (suite *InternalToASTestSuite) TestAccountToASAliasedAndMoved() { suite.FailNow(err.Error()) } - accountable, err := suite.typeconverter.AccountToAS(context.Background(), testAccount) + accountable, err := suite.typeconverter.AccountToAS(suite.T().Context(), testAccount) suite.NoError(err) ser, err := ap.Serialize(accountable) @@ -312,7 +311,7 @@ func (suite *InternalToASTestSuite) TestAccountToASWithOneField() { *testAccount = *suite.testAccounts["local_account_2"] testAccount.Fields = testAccount.Fields[0:1] // Take only one field. - accountable, err := suite.typeconverter.AccountToAS(context.Background(), testAccount) + accountable, err := suite.typeconverter.AccountToAS(suite.T().Context(), testAccount) suite.NoError(err) ser, err := ap.Serialize(accountable) @@ -374,7 +373,7 @@ func (suite *InternalToASTestSuite) TestAccountToASWithEmoji() { *testAccount = *suite.testAccounts["local_account_1"] // take zork for this test testAccount.Emojis = []*gtsmodel.Emoji{suite.testEmojis["rainbow"]} - accountable, err := suite.typeconverter.AccountToAS(context.Background(), testAccount) + accountable, err := suite.typeconverter.AccountToAS(suite.T().Context(), testAccount) suite.NoError(err) ser, err := ap.Serialize(accountable) @@ -447,7 +446,7 @@ func (suite *InternalToASTestSuite) TestAccountToASWithSharedInbox() { sharedInbox := "http://localhost:8080/sharedInbox" testAccount.SharedInboxURI = &sharedInbox - accountable, err := suite.typeconverter.AccountToAS(context.Background(), testAccount) + accountable, err := suite.typeconverter.AccountToAS(suite.T().Context(), testAccount) suite.NoError(err) ser, err := ap.Serialize(accountable) @@ -508,7 +507,7 @@ func (suite *InternalToASTestSuite) TestAccountToASWithSharedInbox() { func (suite *InternalToASTestSuite) TestStatusToAS() { testStatus := suite.testStatuses["local_account_1_status_1"] - ctx := context.Background() + ctx := suite.T().Context() asStatus, err := suite.typeconverter.StatusToAS(ctx, testStatus) suite.NoError(err) @@ -590,7 +589,7 @@ func (suite *InternalToASTestSuite) TestStatusToAS() { func (suite *InternalToASTestSuite) TestStatusWithTagsToASWithIDs() { // use the status with just IDs of attachments and emojis pinned on it testStatus := suite.testStatuses["admin_account_status_1"] - ctx := context.Background() + ctx := suite.T().Context() asStatus, err := suite.typeconverter.StatusToAS(ctx, testStatus) suite.NoError(err) @@ -707,7 +706,7 @@ func (suite *InternalToASTestSuite) TestStatusWithTagsToASWithIDs() { } func (suite *InternalToASTestSuite) TestStatusWithTagsToASFromDB() { - ctx := context.Background() + ctx := suite.T().Context() // get the entire status with all tags testStatus, err := suite.db.GetStatusByID(ctx, suite.testStatuses["admin_account_status_1"].ID) suite.NoError(err) @@ -828,7 +827,7 @@ func (suite *InternalToASTestSuite) TestStatusWithTagsToASFromDB() { func (suite *InternalToASTestSuite) TestStatusToASWithMentions() { testStatusID := suite.testStatuses["admin_account_status_3"].ID - ctx := context.Background() + ctx := suite.T().Context() testStatus, err := suite.db.GetStatusByID(ctx, testStatusID) suite.NoError(err) @@ -920,7 +919,7 @@ func (suite *InternalToASTestSuite) TestStatusToASWithMentions() { func (suite *InternalToASTestSuite) TestStatusToASDeletePublicReply() { testStatus := suite.testStatuses["admin_account_status_3"] - ctx := context.Background() + ctx := suite.T().Context() asDelete, err := suite.typeconverter.StatusToASDelete(ctx, testStatus) suite.NoError(err) @@ -946,7 +945,7 @@ func (suite *InternalToASTestSuite) TestStatusToASDeletePublicReply() { func (suite *InternalToASTestSuite) TestStatusToASDeletePublicReplyOriginalDeleted() { testStatus := suite.testStatuses["admin_account_status_3"] - ctx := context.Background() + ctx := suite.T().Context() // Delete the status this replies to. if err := suite.db.DeleteStatusByID(ctx, testStatus.ID); err != nil { @@ -984,7 +983,7 @@ func (suite *InternalToASTestSuite) TestStatusToASDeletePublicReplyOriginalDelet func (suite *InternalToASTestSuite) TestStatusToASDeletePublic() { testStatus := suite.testStatuses["admin_account_status_1"] - ctx := context.Background() + ctx := suite.T().Context() asDelete, err := suite.typeconverter.StatusToASDelete(ctx, testStatus) suite.NoError(err) @@ -1007,7 +1006,7 @@ func (suite *InternalToASTestSuite) TestStatusToASDeletePublic() { func (suite *InternalToASTestSuite) TestStatusToASDeleteDirectMessage() { testStatus := suite.testStatuses["local_account_2_status_6"] - ctx := context.Background() + ctx := suite.T().Context() asDelete, err := suite.typeconverter.StatusToASDelete(ctx, testStatus) suite.NoError(err) @@ -1030,7 +1029,7 @@ func (suite *InternalToASTestSuite) TestStatusToASDeleteDirectMessage() { func (suite *InternalToASTestSuite) TestStatusesToASOutboxPage() { testAccount := suite.testAccounts["admin_account"] - ctx := context.Background() + ctx := suite.T().Context() // get public statuses from testaccount statuses, err := suite.db.GetAccountStatuses(ctx, testAccount.ID, 30, true, true, "", "", false, true) @@ -1076,7 +1075,7 @@ func (suite *InternalToASTestSuite) TestStatusesToASOutboxPage() { } func (suite *InternalToASTestSuite) TestSelfBoostFollowersOnlyToAS() { - ctx := context.Background() + ctx := suite.T().Context() testStatus := suite.testStatuses["local_account_1_status_5"] testAccount := suite.testAccounts["local_account_1"] @@ -1112,7 +1111,7 @@ func (suite *InternalToASTestSuite) TestSelfBoostFollowersOnlyToAS() { } func (suite *InternalToASTestSuite) TestReportToAS() { - ctx := context.Background() + ctx := suite.T().Context() testReport := suite.testReports["local_account_2_report_remote_account_1"] account := suite.testAccounts["local_account_2"] @@ -1146,7 +1145,7 @@ func (suite *InternalToASTestSuite) TestReportToAS() { } func (suite *InternalToASTestSuite) TestPinnedStatusesToASSomeItems() { - ctx := context.Background() + ctx := suite.T().Context() testAccount := suite.testAccounts["admin_account"] statuses, err := suite.db.GetAccountPinnedStatuses(ctx, testAccount.ID) @@ -1178,7 +1177,7 @@ func (suite *InternalToASTestSuite) TestPinnedStatusesToASSomeItems() { } func (suite *InternalToASTestSuite) TestPinnedStatusesToASNoItems() { - ctx := context.Background() + ctx := suite.T().Context() testAccount := suite.testAccounts["local_account_1"] statuses, err := suite.db.GetAccountPinnedStatuses(ctx, testAccount.ID) @@ -1207,7 +1206,7 @@ func (suite *InternalToASTestSuite) TestPinnedStatusesToASNoItems() { } func (suite *InternalToASTestSuite) TestPinnedStatusesToASOneItem() { - ctx := context.Background() + ctx := suite.T().Context() testAccount := suite.testAccounts["local_account_2"] statuses, err := suite.db.GetAccountPinnedStatuses(ctx, testAccount.ID) @@ -1240,7 +1239,7 @@ func (suite *InternalToASTestSuite) TestPinnedStatusesToASOneItem() { func (suite *InternalToASTestSuite) TestPollVoteToASCreate() { vote := suite.testPollVotes["remote_account_1_status_2_poll_vote_local_account_1"] - creates, err := suite.typeconverter.PollVoteToASCreates(context.Background(), vote) + creates, err := suite.typeconverter.PollVoteToASCreates(suite.T().Context(), vote) suite.NoError(err) suite.Len(creates, 2) @@ -1311,7 +1310,7 @@ func (suite *InternalToASTestSuite) TestInteractionReqToASAcceptAnnounce() { } accept, err := suite.typeconverter.InteractionReqToASAccept( - context.Background(), + suite.T().Context(), req, ) if err != nil { @@ -1363,7 +1362,7 @@ func (suite *InternalToASTestSuite) TestInteractionReqToASAcceptLike() { } accept, err := suite.typeconverter.InteractionReqToASAccept( - context.Background(), + suite.T().Context(), req, ) if err != nil { |
