Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
NyaaaWhatsUpDoc committed Nov 17, 2023
1 parent 209c93e commit 675185c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 17 deletions.
29 changes: 13 additions & 16 deletions internal/api/activitypub/users/repliesget_test.go
Expand Up @@ -93,7 +93,7 @@ func (suite *RepliesGetTestSuite) TestGetReplies() {
"type": "OrderedCollection",
"id": targetStatus.URI + "/replies?only_other_accounts=false",
"first": targetStatus.URI + "/replies?limit=20&only_other_accounts=false",
"totalItems": 2,
"totalItems": 1,
})
assert.Equal(suite.T(), expect, string(b))

Expand Down Expand Up @@ -157,17 +157,14 @@ func (suite *RepliesGetTestSuite) TestGetRepliesNext() {

// Create JSON string of expected output.
expect := toJSON(map[string]any{
"@context": "https://www.w3.org/ns/activitystreams",
"type": "OrderedCollectionPage",
"id": targetStatus.URI + "/replies?limit=20&only_other_accounts=false",
"partOf": targetStatus.URI + "/replies?only_other_accounts=false",
"next": "http://localhost:8080/users/the_mighty_zork/statuses/01F8MHAMCHF6Y650WCRSCP4WMY/replies?limit=20&min_id=01FCQSQ667XHJ9AV9T27SJJSX5&only_other_accounts=false",
"prev": "http://localhost:8080/users/the_mighty_zork/statuses/01F8MHAMCHF6Y650WCRSCP4WMY/replies?limit=20&max_id=01FF25D5Q0DH7CHD57CTRS6WK0&only_other_accounts=false",
"orderedItems": []any{
"http://localhost:8080/users/1happyturtle/statuses/01FCQSQ667XHJ9AV9T27SJJSX5",
"http://localhost:8080/users/admin/statuses/01FF25D5Q0DH7CHD57CTRS6WK0",
},
"totalItems": 2,
"@context": "https://www.w3.org/ns/activitystreams",
"type": "OrderedCollectionPage",
"id": targetStatus.URI + "/replies?limit=20&only_other_accounts=false",
"partOf": targetStatus.URI + "/replies?only_other_accounts=false",
"next": "http://localhost:8080/users/the_mighty_zork/statuses/01F8MHAMCHF6Y650WCRSCP4WMY/replies?limit=20&min_id=01FF25D5Q0DH7CHD57CTRS6WK0&only_other_accounts=false",
"prev": "http://localhost:8080/users/the_mighty_zork/statuses/01F8MHAMCHF6Y650WCRSCP4WMY/replies?limit=20&max_id=01FF25D5Q0DH7CHD57CTRS6WK0&only_other_accounts=false",
"orderedItems": "http://localhost:8080/users/admin/statuses/01FF25D5Q0DH7CHD57CTRS6WK0",
"totalItems": 1,
})
assert.Equal(suite.T(), expect, string(b))

Expand All @@ -181,7 +178,7 @@ func (suite *RepliesGetTestSuite) TestGetRepliesNext() {
page, ok := t.(vocab.ActivityStreamsOrderedCollectionPage)
assert.True(suite.T(), ok)

assert.Equal(suite.T(), page.GetActivityStreamsOrderedItems().Len(), 2)
assert.Equal(suite.T(), page.GetActivityStreamsOrderedItems().Len(), 1)
}

func (suite *RepliesGetTestSuite) TestGetRepliesLast() {
Expand All @@ -194,7 +191,7 @@ func (suite *RepliesGetTestSuite) TestGetRepliesLast() {
// setup request
recorder := httptest.NewRecorder()
ctx, _ := testrig.CreateGinTestContext(recorder, nil)
ctx.Request = httptest.NewRequest(http.MethodGet, targetStatus.URI+"/replies?only_other_accounts=false&page=true&min_id=01FCQSQ667XHJ9AV9T27SJJSX5", nil) // the endpoint we're hitting
ctx.Request = httptest.NewRequest(http.MethodGet, targetStatus.URI+"/replies?min_id=01FF25D5Q0DH7CHD57CTRS6WK0&only_other_accounts=false", nil)
ctx.Request.Header.Set("accept", "application/activity+json")
ctx.Request.Header.Set("Signature", signedRequest.SignatureHeader)
ctx.Request.Header.Set("Date", signedRequest.DateHeader)
Expand Down Expand Up @@ -235,10 +232,10 @@ func (suite *RepliesGetTestSuite) TestGetRepliesLast() {
expect := toJSON(map[string]any{
"@context": "https://www.w3.org/ns/activitystreams",
"type": "OrderedCollectionPage",
"id": targetStatus.URI + "/replies?min_id=01FCQSQ667XHJ9AV9T27SJJSX5&only_other_accounts=false",
"id": targetStatus.URI + "/replies?min_id=01FF25D5Q0DH7CHD57CTRS6WK0&only_other_accounts=false",
"partOf": targetStatus.URI + "/replies?only_other_accounts=false",
"orderedItems": []any{}, // empty
"totalItems": 2,
"totalItems": 1,
})
assert.Equal(suite.T(), expect, string(b))

Expand Down
2 changes: 1 addition & 1 deletion testrig/testmodels.go
Expand Up @@ -3179,7 +3179,7 @@ func NewTestDereferenceRequests(accounts map[string]*gtsmodel.Account) map[strin
DateHeader: date,
}

target = URLMustParse(statuses["local_account_1_status_1"].URI + "/replies?only_other_accounts=false&page=true&min_id=01FCQSQ667XHJ9AV9T27SJJSX5")
target = URLMustParse(statuses["local_account_1_status_1"].URI + "/replies?min_id=01FF25D5Q0DH7CHD57CTRS6WK0&only_other_accounts=false")
sig, digest, date = GetSignatureForDereference(accounts["remote_account_1"].PublicKeyURI, accounts["remote_account_1"].PrivateKey, target)
fossSatanDereferenceLocalAccount1Status1RepliesLast := ActivityWithSignature{
SignatureHeader: sig,
Expand Down

0 comments on commit 675185c

Please sign in to comment.