summaryrefslogtreecommitdiff
path: root/internal/typeutils/astointernal_test.go
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2023-12-01 15:27:15 +0100
committerLibravatar GitHub <noreply@github.com>2023-12-01 15:27:15 +0100
commit0e2c34219112db3a6b7801530a946fd5b1bbb111 (patch)
tree6a5557373dbfc9edc80de941b13e870a8af32881 /internal/typeutils/astointernal_test.go
parent[bugfix] in fedi API CreateStatus(), handle case of data-race and return earl... (diff)
downloadgotosocial-0e2c34219112db3a6b7801530a946fd5b1bbb111.tar.xz
[bugfix/chore] `Announce` reliability updates (#2405)v0.13.0-rc1
* [bugfix/chore] `Announce` updates * test update * fix tests * TestParseAnnounce * update comments * don't lock/unlock, change function signature * naming stuff * don't check domain block twice * UnwrapIfBoost * beep boop
Diffstat (limited to 'internal/typeutils/astointernal_test.go')
-rw-r--r--internal/typeutils/astointernal_test.go40
1 files changed, 40 insertions, 0 deletions
diff --git a/internal/typeutils/astointernal_test.go b/internal/typeutils/astointernal_test.go
index 40bf4c855..4be2434e5 100644
--- a/internal/typeutils/astointernal_test.go
+++ b/internal/typeutils/astointernal_test.go
@@ -463,6 +463,46 @@ func (suite *ASToInternalTestSuite) TestParseFlag6() {
suite.Equal(report.Comment, "misinformation")
}
+func (suite *ASToInternalTestSuite) TestParseAnnounce() {
+ // Boost a status that belongs to a local account
+ boostingAccount := suite.testAccounts["remote_account_1"]
+ targetStatus := suite.testStatuses["local_account_2_status_1"]
+ receivingAccount := suite.testAccounts["local_account_1"]
+
+ raw := `{
+ "@context": "https://www.w3.org/ns/activitystreams",
+ "actor": "` + boostingAccount.URI + `",
+ "id": "http://fossbros-anonymous.io/db22128d-884e-4358-9935-6a7c3940535d",
+ "object": ["` + targetStatus.URI + `"],
+ "type": "Announce",
+ "to": "` + receivingAccount.URI + `"
+ }`
+
+ t := suite.jsonToType(raw)
+ asAnnounce, ok := t.(ap.Announceable)
+ if !ok {
+ suite.FailNow("type not coercible")
+ }
+
+ boost, isNew, err := suite.typeconverter.ASAnnounceToStatus(context.Background(), asAnnounce)
+ if err != nil {
+ suite.FailNow(err.Error())
+ }
+
+ suite.True(isNew)
+ suite.NotNil(boost)
+ suite.Equal(boostingAccount.ID, boost.AccountID)
+ suite.NotNil(boost.Account)
+
+ // Of the 'BoostOf' fields, only BoostOfURI will be set.
+ // Others are set in dereferencing.EnrichAnnounceSafely.
+ suite.Equal(targetStatus.URI, boost.BoostOfURI)
+ suite.Empty(boost.BoostOfID)
+ suite.Nil(boost.BoostOf)
+ suite.Empty(boost.BoostOfAccountID)
+ suite.Nil(boost.BoostOfAccount)
+}
+
func TestASToInternalTestSuite(t *testing.T) {
suite.Run(t, new(ASToInternalTestSuite))
}