mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-15 08:57:29 -06:00
[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>
This commit is contained in:
parent
ec4d4d0115
commit
d5c9c4adc1
175 changed files with 857 additions and 1004 deletions
|
|
@ -51,7 +51,7 @@ func (suite *AccountTestSuite) TestDereferenceGroup() {
|
|||
|
||||
groupURL := testrig.URLMustParse("https://unknown-instance.com/groups/some_group")
|
||||
group, _, err := suite.dereferencer.GetAccountByURI(
|
||||
context.Background(),
|
||||
suite.T().Context(),
|
||||
fetchingAccount.Username,
|
||||
groupURL,
|
||||
false,
|
||||
|
|
@ -65,7 +65,7 @@ func (suite *AccountTestSuite) TestDereferenceGroup() {
|
|||
suite.WithinDuration(time.Now(), group.FetchedAt, 5*time.Second)
|
||||
|
||||
// group should be in the database
|
||||
dbGroup, err := suite.db.GetAccountByURI(context.Background(), group.URI)
|
||||
dbGroup, err := suite.db.GetAccountByURI(suite.T().Context(), group.URI)
|
||||
suite.NoError(err)
|
||||
suite.Equal(group.ID, dbGroup.ID)
|
||||
suite.Equal(ap.ActorGroup, dbGroup.ActorType.String())
|
||||
|
|
@ -76,7 +76,7 @@ func (suite *AccountTestSuite) TestDereferenceService() {
|
|||
|
||||
serviceURL := testrig.URLMustParse("https://owncast.example.org/federation/user/rgh")
|
||||
service, _, err := suite.dereferencer.GetAccountByURI(
|
||||
context.Background(),
|
||||
suite.T().Context(),
|
||||
fetchingAccount.Username,
|
||||
serviceURL,
|
||||
false,
|
||||
|
|
@ -90,7 +90,7 @@ func (suite *AccountTestSuite) TestDereferenceService() {
|
|||
suite.WithinDuration(time.Now(), service.FetchedAt, 5*time.Second)
|
||||
|
||||
// service should be in the database
|
||||
dbService, err := suite.db.GetAccountByURI(context.Background(), service.URI)
|
||||
dbService, err := suite.db.GetAccountByURI(suite.T().Context(), service.URI)
|
||||
suite.NoError(err)
|
||||
suite.Equal(service.ID, dbService.ID)
|
||||
suite.Equal(ap.ActorService, dbService.ActorType.String())
|
||||
|
|
@ -109,7 +109,7 @@ func (suite *AccountTestSuite) TestDereferenceLocalAccountAsRemoteURL() {
|
|||
targetAccount := suite.testAccounts["local_account_2"]
|
||||
|
||||
fetchedAccount, _, err := suite.dereferencer.GetAccountByURI(
|
||||
context.Background(),
|
||||
suite.T().Context(),
|
||||
fetchingAccount.Username,
|
||||
testrig.URLMustParse(targetAccount.URI),
|
||||
false,
|
||||
|
|
@ -124,12 +124,12 @@ func (suite *AccountTestSuite) TestDereferenceLocalAccountAsRemoteURLNoSharedInb
|
|||
targetAccount := suite.testAccounts["local_account_2"]
|
||||
|
||||
targetAccount.SharedInboxURI = nil
|
||||
if err := suite.db.UpdateAccount(context.Background(), targetAccount); err != nil {
|
||||
if err := suite.db.UpdateAccount(suite.T().Context(), targetAccount); err != nil {
|
||||
suite.FailNow(err.Error())
|
||||
}
|
||||
|
||||
fetchedAccount, _, err := suite.dereferencer.GetAccountByURI(
|
||||
context.Background(),
|
||||
suite.T().Context(),
|
||||
fetchingAccount.Username,
|
||||
testrig.URLMustParse(targetAccount.URI),
|
||||
false,
|
||||
|
|
@ -144,7 +144,7 @@ func (suite *AccountTestSuite) TestDereferenceLocalAccountAsUsername() {
|
|||
targetAccount := suite.testAccounts["local_account_2"]
|
||||
|
||||
fetchedAccount, _, err := suite.dereferencer.GetAccountByURI(
|
||||
context.Background(),
|
||||
suite.T().Context(),
|
||||
fetchingAccount.Username,
|
||||
testrig.URLMustParse(targetAccount.URI),
|
||||
false,
|
||||
|
|
@ -159,7 +159,7 @@ func (suite *AccountTestSuite) TestDereferenceLocalAccountAsUsernameDomain() {
|
|||
targetAccount := suite.testAccounts["local_account_2"]
|
||||
|
||||
fetchedAccount, _, err := suite.dereferencer.GetAccountByURI(
|
||||
context.Background(),
|
||||
suite.T().Context(),
|
||||
fetchingAccount.Username,
|
||||
testrig.URLMustParse(targetAccount.URI),
|
||||
false,
|
||||
|
|
@ -174,7 +174,7 @@ func (suite *AccountTestSuite) TestDereferenceLocalAccountAsUsernameDomainAndURL
|
|||
targetAccount := suite.testAccounts["local_account_2"]
|
||||
|
||||
fetchedAccount, _, err := suite.dereferencer.GetAccountByUsernameDomain(
|
||||
context.Background(),
|
||||
suite.T().Context(),
|
||||
fetchingAccount.Username,
|
||||
targetAccount.Username,
|
||||
config.GetHost(),
|
||||
|
|
@ -188,7 +188,7 @@ func (suite *AccountTestSuite) TestDereferenceLocalAccountWithUnknownUsername()
|
|||
fetchingAccount := suite.testAccounts["local_account_1"]
|
||||
|
||||
fetchedAccount, _, err := suite.dereferencer.GetAccountByUsernameDomain(
|
||||
context.Background(),
|
||||
suite.T().Context(),
|
||||
fetchingAccount.Username,
|
||||
"thisaccountdoesnotexist",
|
||||
config.GetHost(),
|
||||
|
|
@ -202,7 +202,7 @@ func (suite *AccountTestSuite) TestDereferenceLocalAccountWithUnknownUsernameDom
|
|||
fetchingAccount := suite.testAccounts["local_account_1"]
|
||||
|
||||
fetchedAccount, _, err := suite.dereferencer.GetAccountByUsernameDomain(
|
||||
context.Background(),
|
||||
suite.T().Context(),
|
||||
fetchingAccount.Username,
|
||||
"thisaccountdoesnotexist",
|
||||
"localhost:8080",
|
||||
|
|
@ -216,7 +216,7 @@ func (suite *AccountTestSuite) TestDereferenceLocalAccountWithUnknownUserURI() {
|
|||
fetchingAccount := suite.testAccounts["local_account_1"]
|
||||
|
||||
fetchedAccount, _, err := suite.dereferencer.GetAccountByURI(
|
||||
context.Background(),
|
||||
suite.T().Context(),
|
||||
fetchingAccount.Username,
|
||||
testrig.URLMustParse("http://localhost:8080/users/thisaccountdoesnotexist"),
|
||||
false,
|
||||
|
|
@ -227,7 +227,7 @@ func (suite *AccountTestSuite) TestDereferenceLocalAccountWithUnknownUserURI() {
|
|||
}
|
||||
|
||||
func (suite *AccountTestSuite) TestDereferenceLocalAccountByRedirect() {
|
||||
ctx, cncl := context.WithCancel(context.Background())
|
||||
ctx, cncl := context.WithCancel(suite.T().Context())
|
||||
defer cncl()
|
||||
|
||||
fetchingAccount := suite.testAccounts["local_account_1"]
|
||||
|
|
@ -280,7 +280,7 @@ func (suite *AccountTestSuite) TestDereferenceLocalAccountByRedirect() {
|
|||
}
|
||||
|
||||
func (suite *AccountTestSuite) TestDereferenceMasqueradingLocalAccount() {
|
||||
ctx, cncl := context.WithCancel(context.Background())
|
||||
ctx, cncl := context.WithCancel(suite.T().Context())
|
||||
defer cncl()
|
||||
|
||||
fetchingAccount := suite.testAccounts["local_account_1"]
|
||||
|
|
@ -345,7 +345,7 @@ func (suite *AccountTestSuite) TestDereferenceRemoteAccountWithNonMatchingURI()
|
|||
|
||||
// Attempt to fetch account at alternative URI, it should fail!
|
||||
fetchedAccount, _, err := suite.dereferencer.GetAccountByURI(
|
||||
context.Background(),
|
||||
suite.T().Context(),
|
||||
fetchingAccount.Username,
|
||||
testrig.URLMustParse(remoteAltURI),
|
||||
false,
|
||||
|
|
@ -355,7 +355,7 @@ func (suite *AccountTestSuite) TestDereferenceRemoteAccountWithNonMatchingURI()
|
|||
}
|
||||
|
||||
func (suite *AccountTestSuite) TestDereferenceRemoteAccountWithUnexpectedKeyChange() {
|
||||
ctx, cncl := context.WithCancel(context.Background())
|
||||
ctx, cncl := context.WithCancel(suite.T().Context())
|
||||
defer cncl()
|
||||
|
||||
fetchingAcc := suite.testAccounts["local_account_1"]
|
||||
|
|
@ -394,7 +394,7 @@ func (suite *AccountTestSuite) TestDereferenceRemoteAccountWithUnexpectedKeyChan
|
|||
}
|
||||
|
||||
func (suite *AccountTestSuite) TestDereferenceRemoteAccountWithExpectedKeyChange() {
|
||||
ctx, cncl := context.WithCancel(context.Background())
|
||||
ctx, cncl := context.WithCancel(suite.T().Context())
|
||||
defer cncl()
|
||||
|
||||
fetchingAcc := suite.testAccounts["local_account_1"]
|
||||
|
|
@ -436,7 +436,7 @@ func (suite *AccountTestSuite) TestDereferenceRemoteAccountWithExpectedKeyChange
|
|||
}
|
||||
|
||||
func (suite *AccountTestSuite) TestRefreshFederatedRemoteAccountWithKeyChange() {
|
||||
ctx, cncl := context.WithCancel(context.Background())
|
||||
ctx, cncl := context.WithCancel(suite.T().Context())
|
||||
defer cncl()
|
||||
|
||||
fetchingAcc := suite.testAccounts["local_account_1"]
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@
|
|||
package dereferencing_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"testing"
|
||||
"time"
|
||||
|
|
@ -32,7 +31,7 @@ type EmojiTestSuite struct {
|
|||
}
|
||||
|
||||
func (suite *EmojiTestSuite) TestDereferenceEmojiBlocking() {
|
||||
ctx := context.Background()
|
||||
ctx := suite.T().Context()
|
||||
emojiImageRemoteURL := "http://example.org/media/emojis/1781772.gif"
|
||||
emojiImageStaticRemoteURL := "http://example.org/media/emojis/1781772.gif"
|
||||
emojiURI := "http://example.org/emojis/1781772"
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@
|
|||
package dereferencing_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/url"
|
||||
"testing"
|
||||
|
||||
|
|
@ -77,7 +76,7 @@ func (suite *InstanceTestSuite) TestDerefInstance() {
|
|||
},
|
||||
} {
|
||||
instance, err := suite.dereferencer.GetRemoteInstance(
|
||||
gtscontext.SetFastFail(context.Background()),
|
||||
gtscontext.SetFastFail(suite.T().Context()),
|
||||
suite.testAccounts["admin_account"].Username,
|
||||
tc.instanceIRI,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ func (suite *StatusTestSuite) TestDereferenceSimpleStatus() {
|
|||
fetchingAccount := suite.testAccounts["local_account_1"]
|
||||
|
||||
statusURL := testrig.URLMustParse("https://unknown-instance.com/users/brand_new_person/statuses/01FE4NTHKWW7THT67EF10EB839")
|
||||
status, _, err := suite.dereferencer.GetStatusByURI(context.Background(), fetchingAccount.Username, statusURL)
|
||||
status, _, err := suite.dereferencer.GetStatusByURI(suite.T().Context(), fetchingAccount.Username, statusURL)
|
||||
suite.NoError(err)
|
||||
suite.NotNil(status)
|
||||
|
||||
|
|
@ -59,13 +59,13 @@ func (suite *StatusTestSuite) TestDereferenceSimpleStatus() {
|
|||
suite.Equal(ap.ObjectNote, status.ActivityStreamsType)
|
||||
|
||||
// status should be in the database
|
||||
dbStatus, err := suite.db.GetStatusByURI(context.Background(), status.URI)
|
||||
dbStatus, err := suite.db.GetStatusByURI(suite.T().Context(), status.URI)
|
||||
suite.NoError(err)
|
||||
suite.Equal(status.ID, dbStatus.ID)
|
||||
suite.True(*dbStatus.Federated)
|
||||
|
||||
// account should be in the database now too
|
||||
account, err := suite.db.GetAccountByURI(context.Background(), status.AccountURI)
|
||||
account, err := suite.db.GetAccountByURI(suite.T().Context(), status.AccountURI)
|
||||
suite.NoError(err)
|
||||
suite.NotNil(account)
|
||||
suite.True(*account.Discoverable)
|
||||
|
|
@ -81,7 +81,7 @@ func (suite *StatusTestSuite) TestDereferenceStatusWithMention() {
|
|||
fetchingAccount := suite.testAccounts["local_account_1"]
|
||||
|
||||
statusURL := testrig.URLMustParse("https://unknown-instance.com/users/brand_new_person/statuses/01FE5Y30E3W4P7TRE0R98KAYQV")
|
||||
status, _, err := suite.dereferencer.GetStatusByURI(context.Background(), fetchingAccount.Username, statusURL)
|
||||
status, _, err := suite.dereferencer.GetStatusByURI(suite.T().Context(), fetchingAccount.Username, statusURL)
|
||||
suite.NoError(err)
|
||||
suite.NotNil(status)
|
||||
|
||||
|
|
@ -96,13 +96,13 @@ func (suite *StatusTestSuite) TestDereferenceStatusWithMention() {
|
|||
suite.Equal(ap.ObjectNote, status.ActivityStreamsType)
|
||||
|
||||
// status should be in the database
|
||||
dbStatus, err := suite.db.GetStatusByURI(context.Background(), status.URI)
|
||||
dbStatus, err := suite.db.GetStatusByURI(suite.T().Context(), status.URI)
|
||||
suite.NoError(err)
|
||||
suite.Equal(status.ID, dbStatus.ID)
|
||||
suite.True(*dbStatus.Federated)
|
||||
|
||||
// account should be in the database now too
|
||||
account, err := suite.db.GetAccountByURI(context.Background(), status.AccountURI)
|
||||
account, err := suite.db.GetAccountByURI(suite.T().Context(), status.AccountURI)
|
||||
suite.NoError(err)
|
||||
suite.NotNil(account)
|
||||
suite.True(*account.Discoverable)
|
||||
|
|
@ -115,7 +115,7 @@ func (suite *StatusTestSuite) TestDereferenceStatusWithMention() {
|
|||
|
||||
// we should have a mention in the database
|
||||
m := >smodel.Mention{}
|
||||
err = suite.db.GetWhere(context.Background(), []db.Where{{Key: "status_id", Value: status.ID}}, m)
|
||||
err = suite.db.GetWhere(suite.T().Context(), []db.Where{{Key: "status_id", Value: status.ID}}, m)
|
||||
suite.NoError(err)
|
||||
suite.NotNil(m)
|
||||
suite.Equal(status.ID, m.StatusID)
|
||||
|
|
@ -129,7 +129,7 @@ func (suite *StatusTestSuite) TestDereferenceStatusWithTag() {
|
|||
fetchingAccount := suite.testAccounts["local_account_1"]
|
||||
|
||||
statusURL := testrig.URLMustParse("https://unknown-instance.com/users/brand_new_person/statuses/01H641QSRS3TCXSVC10X4GPKW7")
|
||||
status, _, err := suite.dereferencer.GetStatusByURI(context.Background(), fetchingAccount.Username, statusURL)
|
||||
status, _, err := suite.dereferencer.GetStatusByURI(suite.T().Context(), fetchingAccount.Username, statusURL)
|
||||
suite.NoError(err)
|
||||
suite.NotNil(status)
|
||||
|
||||
|
|
@ -148,13 +148,13 @@ func (suite *StatusTestSuite) TestDereferenceStatusWithTag() {
|
|||
suite.Len(status.TagIDs, 1)
|
||||
|
||||
// status should be in the database
|
||||
dbStatus, err := suite.db.GetStatusByURI(context.Background(), status.URI)
|
||||
dbStatus, err := suite.db.GetStatusByURI(suite.T().Context(), status.URI)
|
||||
suite.NoError(err)
|
||||
suite.Equal(status.ID, dbStatus.ID)
|
||||
suite.True(*dbStatus.Federated)
|
||||
|
||||
// account should be in the database now too
|
||||
account, err := suite.db.GetAccountByURI(context.Background(), status.AccountURI)
|
||||
account, err := suite.db.GetAccountByURI(suite.T().Context(), status.AccountURI)
|
||||
suite.NoError(err)
|
||||
suite.NotNil(account)
|
||||
suite.True(*account.Discoverable)
|
||||
|
|
@ -167,7 +167,7 @@ func (suite *StatusTestSuite) TestDereferenceStatusWithTag() {
|
|||
|
||||
// we should have a tag in the database
|
||||
t := >smodel.Tag{}
|
||||
err = suite.db.GetWhere(context.Background(), []db.Where{{Key: "name", Value: "piss"}}, t)
|
||||
err = suite.db.GetWhere(suite.T().Context(), []db.Where{{Key: "name", Value: "piss"}}, t)
|
||||
suite.NoError(err)
|
||||
suite.NotNil(t)
|
||||
}
|
||||
|
|
@ -176,7 +176,7 @@ func (suite *StatusTestSuite) TestDereferenceStatusWithImageAndNoContent() {
|
|||
fetchingAccount := suite.testAccounts["local_account_1"]
|
||||
|
||||
statusURL := testrig.URLMustParse("https://turnip.farm/users/turniplover6969/statuses/70c53e54-3146-42d5-a630-83c8b6c7c042")
|
||||
status, _, err := suite.dereferencer.GetStatusByURI(context.Background(), fetchingAccount.Username, statusURL)
|
||||
status, _, err := suite.dereferencer.GetStatusByURI(suite.T().Context(), fetchingAccount.Username, statusURL)
|
||||
suite.NoError(err)
|
||||
suite.NotNil(status)
|
||||
|
||||
|
|
@ -191,13 +191,13 @@ func (suite *StatusTestSuite) TestDereferenceStatusWithImageAndNoContent() {
|
|||
suite.Equal(ap.ObjectNote, status.ActivityStreamsType)
|
||||
|
||||
// status should be in the database
|
||||
dbStatus, err := suite.db.GetStatusByURI(context.Background(), status.URI)
|
||||
dbStatus, err := suite.db.GetStatusByURI(suite.T().Context(), status.URI)
|
||||
suite.NoError(err)
|
||||
suite.Equal(status.ID, dbStatus.ID)
|
||||
suite.True(*dbStatus.Federated)
|
||||
|
||||
// account should be in the database now too
|
||||
account, err := suite.db.GetAccountByURI(context.Background(), status.AccountURI)
|
||||
account, err := suite.db.GetAccountByURI(suite.T().Context(), status.AccountURI)
|
||||
suite.NoError(err)
|
||||
suite.NotNil(account)
|
||||
suite.True(*account.Discoverable)
|
||||
|
|
@ -210,7 +210,7 @@ func (suite *StatusTestSuite) TestDereferenceStatusWithImageAndNoContent() {
|
|||
|
||||
// we should have an attachment in the database
|
||||
a := >smodel.MediaAttachment{}
|
||||
err = suite.db.GetWhere(context.Background(), []db.Where{{Key: "status_id", Value: status.ID}}, a)
|
||||
err = suite.db.GetWhere(suite.T().Context(), []db.Where{{Key: "status_id", Value: status.ID}}, a)
|
||||
suite.NoError(err)
|
||||
}
|
||||
|
||||
|
|
@ -228,7 +228,7 @@ func (suite *StatusTestSuite) TestDereferenceStatusWithNonMatchingURI() {
|
|||
|
||||
// Attempt to fetch account at alternative URI, it should fail!
|
||||
fetchedStatus, _, err := suite.dereferencer.GetStatusByURI(
|
||||
context.Background(),
|
||||
suite.T().Context(),
|
||||
fetchingAccount.Username,
|
||||
testrig.URLMustParse(remoteAltURI),
|
||||
)
|
||||
|
|
@ -238,7 +238,7 @@ func (suite *StatusTestSuite) TestDereferenceStatusWithNonMatchingURI() {
|
|||
|
||||
func (suite *StatusTestSuite) TestDereferencerRefreshStatusUpdated() {
|
||||
// Create a new context for this test.
|
||||
ctx, cncl := context.WithCancel(context.Background())
|
||||
ctx, cncl := context.WithCancel(suite.T().Context())
|
||||
defer cncl()
|
||||
|
||||
// The local account we will be fetching statuses as.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue