mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2025-06-05 21:59:39 +02: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:
@@ -75,7 +75,7 @@ type ConversationsTestSuite struct {
|
||||
}
|
||||
|
||||
func (suite *ConversationsTestSuite) getClientMsg(timeout time.Duration) (*messages.FromClientAPI, bool) {
|
||||
ctx := context.Background()
|
||||
ctx := suite.T().Context()
|
||||
ctx, cncl := context.WithTimeout(ctx, timeout)
|
||||
defer cncl()
|
||||
return suite.state.Workers.Client.Queue.PopCtx(ctx)
|
||||
@@ -130,8 +130,8 @@ func (suite *ConversationsTestSuite) TearDownTest() {
|
||||
(*gtsmodel.ConversationToStatus)(nil),
|
||||
}
|
||||
for _, model := range conversationModels {
|
||||
if err := suite.db.DropTable(context.Background(), model); err != nil {
|
||||
log.Error(context.Background(), err)
|
||||
if err := suite.db.DropTable(suite.T().Context(), model); err != nil {
|
||||
log.Error(suite.T().Context(), err)
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -17,11 +17,9 @@
|
||||
|
||||
package conversations_test
|
||||
|
||||
import "context"
|
||||
|
||||
func (suite *ConversationsTestSuite) TestDelete() {
|
||||
conversation := suite.NewTestConversation(suite.testAccount, 0)
|
||||
|
||||
err := suite.conversationsProcessor.Delete(context.Background(), suite.testAccount, conversation.ID)
|
||||
err := suite.conversationsProcessor.Delete(suite.T().Context(), suite.testAccount, conversation.ID)
|
||||
suite.NoError(err)
|
||||
}
|
||||
|
@@ -18,7 +18,6 @@
|
||||
package conversations_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
apimodel "code.superseriousbusiness.org/gotosocial/internal/api/model"
|
||||
@@ -27,7 +26,7 @@ import (
|
||||
func (suite *ConversationsTestSuite) TestGetAll() {
|
||||
conversation := suite.NewTestConversation(suite.testAccount, 0)
|
||||
|
||||
resp, err := suite.conversationsProcessor.GetAll(context.Background(), suite.testAccount, nil)
|
||||
resp, err := suite.conversationsProcessor.GetAll(suite.T().Context(), suite.testAccount, nil)
|
||||
if suite.NoError(err) && suite.Len(resp.Items, 1) && suite.IsType((*apimodel.Conversation)(nil), resp.Items[0]) {
|
||||
apiConversation := resp.Items[0].(*apimodel.Conversation)
|
||||
suite.Equal(conversation.ID, apiConversation.ID)
|
||||
@@ -46,11 +45,11 @@ func (suite *ConversationsTestSuite) TestGetAllOrder() {
|
||||
// Add an even newer status than that to conversation1.
|
||||
conversation1Status2 := suite.NewTestStatus(suite.testAccount, conversation1.LastStatus.ThreadID, 2*time.Second, conversation1.LastStatus)
|
||||
conversation1.LastStatusID = conversation1Status2.ID
|
||||
if err := suite.db.UpsertConversation(context.Background(), conversation1, "last_status_id"); err != nil {
|
||||
if err := suite.db.UpsertConversation(suite.T().Context(), conversation1, "last_status_id"); err != nil {
|
||||
suite.FailNow(err.Error())
|
||||
}
|
||||
|
||||
resp, err := suite.conversationsProcessor.GetAll(context.Background(), suite.testAccount, nil)
|
||||
resp, err := suite.conversationsProcessor.GetAll(suite.T().Context(), suite.testAccount, nil)
|
||||
if suite.NoError(err) && suite.Len(resp.Items, 2) {
|
||||
// conversation1 should be the first conversation returned.
|
||||
apiConversation1 := resp.Items[0].(*apimodel.Conversation)
|
||||
|
@@ -18,8 +18,6 @@
|
||||
package conversations_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"code.superseriousbusiness.org/gotosocial/internal/db"
|
||||
"code.superseriousbusiness.org/gotosocial/internal/db/bundb"
|
||||
"code.superseriousbusiness.org/gotosocial/internal/gtsmodel"
|
||||
@@ -29,7 +27,7 @@ import (
|
||||
// This test assumes that we're using the standard test fixtures, which contain some conversation-eligible DMs.
|
||||
func (suite *ConversationsTestSuite) TestMigrateDMsToConversations() {
|
||||
advancedMigrationID := "20240611190733_add_conversations"
|
||||
ctx := context.Background()
|
||||
ctx := suite.T().Context()
|
||||
rawDB := (suite.db).(*bundb.DBService).DB()
|
||||
|
||||
// Precondition: we shouldn't have any conversations yet.
|
||||
|
@@ -18,8 +18,6 @@
|
||||
package conversations_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"code.superseriousbusiness.org/gotosocial/internal/util"
|
||||
)
|
||||
|
||||
@@ -27,7 +25,7 @@ func (suite *ConversationsTestSuite) TestRead() {
|
||||
conversation := suite.NewTestConversation(suite.testAccount, 0)
|
||||
|
||||
suite.False(util.PtrOrValue(conversation.Read, false))
|
||||
apiConversation, err := suite.conversationsProcessor.Read(context.Background(), suite.testAccount, conversation.ID)
|
||||
apiConversation, err := suite.conversationsProcessor.Read(suite.T().Context(), suite.testAccount, conversation.ID)
|
||||
if suite.NoError(err) {
|
||||
suite.False(apiConversation.Unread)
|
||||
}
|
||||
|
@@ -17,13 +17,9 @@
|
||||
|
||||
package conversations_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
)
|
||||
|
||||
// Test that we can create conversations when a new status comes in.
|
||||
func (suite *ConversationsTestSuite) TestUpdateConversationsForStatus() {
|
||||
ctx := context.Background()
|
||||
ctx := suite.T().Context()
|
||||
|
||||
// Precondition: the test user shouldn't have any conversations yet.
|
||||
conversations, err := suite.db.GetConversationsByOwnerAccountID(ctx, suite.testAccount.ID, nil)
|
||||
|
Reference in New Issue
Block a user