summaryrefslogtreecommitdiff
path: root/internal/db/bundb/relationship_test.go
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2023-03-31 12:16:25 +0200
committerLibravatar GitHub <noreply@github.com>2023-03-31 11:16:25 +0100
commit344c7e5cbd905c27bdfd1c2c499b660e16995066 (patch)
tree8849a942d0f6a5f4b05d78c35e11f1621fa9523f /internal/db/bundb/relationship_test.go
parent[docs] Add MASH as 3rd party packaging (#1654) (diff)
downloadgotosocial-344c7e5cbd905c27bdfd1c2c499b660e16995066.tar.xz
[bugfix] Fix relationship not updating 'following' on accept follow request (#1658)
Diffstat (limited to 'internal/db/bundb/relationship_test.go')
-rw-r--r--internal/db/bundb/relationship_test.go28
1 files changed, 26 insertions, 2 deletions
diff --git a/internal/db/bundb/relationship_test.go b/internal/db/bundb/relationship_test.go
index 00583d175..9e5a71d60 100644
--- a/internal/db/bundb/relationship_test.go
+++ b/internal/db/bundb/relationship_test.go
@@ -568,6 +568,14 @@ func (suite *RelationshipTestSuite) TestAcceptFollowRequestOK() {
account := suite.testAccounts["admin_account"]
targetAccount := suite.testAccounts["local_account_2"]
+ // Fetch relationship before follow request.
+ relationship, err := suite.db.GetRelationship(ctx, account.ID, targetAccount.ID)
+ if err != nil {
+ suite.FailNow(err.Error())
+ }
+ suite.False(relationship.Following)
+ suite.False(relationship.Requested)
+
followRequest := &gtsmodel.FollowRequest{
ID: "01GEF753FWHCHRDWR0QEHBXM8W",
URI: "http://localhost:8080/weeeeeeeeeeeeeeeee",
@@ -575,10 +583,18 @@ func (suite *RelationshipTestSuite) TestAcceptFollowRequestOK() {
TargetAccountID: targetAccount.ID,
}
- if err := suite.db.Put(ctx, followRequest); err != nil {
+ if err := suite.db.PutFollowRequest(ctx, followRequest); err != nil {
suite.FailNow(err.Error())
}
+ // Fetch relationship while follow requested.
+ relationship, err = suite.db.GetRelationship(ctx, account.ID, targetAccount.ID)
+ if err != nil {
+ suite.FailNow(err.Error())
+ }
+ suite.False(relationship.Following)
+ suite.True(relationship.Requested)
+
followRequestNotification := &gtsmodel.Notification{
ID: "01GV8MY1Q9KX2ZSWN4FAQ3V1PB",
OriginAccountID: account.ID,
@@ -586,7 +602,7 @@ func (suite *RelationshipTestSuite) TestAcceptFollowRequestOK() {
NotificationType: gtsmodel.NotificationFollowRequest,
}
- if err := suite.db.Put(ctx, followRequestNotification); err != nil {
+ if err := suite.db.PutNotification(ctx, followRequestNotification); err != nil {
suite.FailNow(err.Error())
}
@@ -599,6 +615,14 @@ func (suite *RelationshipTestSuite) TestAcceptFollowRequestOK() {
notification, err := suite.db.GetNotificationByID(ctx, followRequestNotification.ID)
suite.ErrorIs(err, db.ErrNoEntries)
suite.Nil(notification)
+
+ // Fetch relationship while followed.
+ relationship, err = suite.db.GetRelationship(ctx, account.ID, targetAccount.ID)
+ if err != nil {
+ suite.FailNow(err.Error())
+ }
+ suite.True(relationship.Following)
+ suite.False(relationship.Requested)
}
func (suite *RelationshipTestSuite) TestAcceptFollowRequestNoNotification() {