diff options
author | 2024-07-11 16:44:29 +0200 | |
---|---|---|
committer | 2024-07-11 15:44:29 +0100 | |
commit | 5bc567196bf2204272950c525e8592e56057c3bd (patch) | |
tree | 24aec5e75d2a0208505da16ee2c55efd887d3e25 /internal/api/client/statuses/statusfave_test.go | |
parent | [bugfix] Don't throw error when parent statuses are missing (#2011) (#3088) (diff) | |
download | gotosocial-5bc567196bf2204272950c525e8592e56057c3bd.tar.xz |
[chore] Add interaction policy gtsmodels (#3075)
* [chore] introduce interaction policy gts models
* update migration a smidge
* fix copy paste typo
* update migration
* use int for InteractionType
Diffstat (limited to 'internal/api/client/statuses/statusfave_test.go')
-rw-r--r-- | internal/api/client/statuses/statusfave_test.go | 73 |
1 files changed, 37 insertions, 36 deletions
diff --git a/internal/api/client/statuses/statusfave_test.go b/internal/api/client/statuses/statusfave_test.go index ebe4603a8..5a35351e4 100644 --- a/internal/api/client/statuses/statusfave_test.go +++ b/internal/api/client/statuses/statusfave_test.go @@ -89,42 +89,43 @@ func (suite *StatusFaveTestSuite) TestPostFave() { } // try to fave a status that's not faveable -func (suite *StatusFaveTestSuite) TestPostUnfaveable() { - t := suite.testTokens["local_account_1"] - oauthToken := oauth.DBTokenToToken(t) - - targetStatus := suite.testStatuses["local_account_2_status_3"] // this one is unlikeable and unreplyable - - // setup - recorder := httptest.NewRecorder() - ctx, _ := testrig.CreateGinTestContext(recorder, nil) - ctx.Set(oauth.SessionAuthorizedApplication, suite.testApplications["application_1"]) - ctx.Set(oauth.SessionAuthorizedToken, oauthToken) - ctx.Set(oauth.SessionAuthorizedUser, suite.testUsers["local_account_1"]) - ctx.Set(oauth.SessionAuthorizedAccount, suite.testAccounts["local_account_1"]) - ctx.Request = httptest.NewRequest(http.MethodPost, fmt.Sprintf("http://localhost:8080%s", strings.Replace(statuses.FavouritePath, ":id", targetStatus.ID, 1)), nil) // the endpoint we're hitting - ctx.Request.Header.Set("accept", "application/json") - - // normally the router would populate these params from the path values, - // but because we're calling the function directly, we need to set them manually. - ctx.Params = gin.Params{ - gin.Param{ - Key: statuses.IDKey, - Value: targetStatus.ID, - }, - } - - suite.statusModule.StatusFavePOSTHandler(ctx) - - // check response - suite.EqualValues(http.StatusForbidden, recorder.Code) - - result := recorder.Result() - defer result.Body.Close() - b, err := ioutil.ReadAll(result.Body) - assert.NoError(suite.T(), err) - assert.Equal(suite.T(), `{"error":"Forbidden: status is not faveable"}`, string(b)) -} +// TODO: replace this when interaction policies enforced. +// func (suite *StatusFaveTestSuite) TestPostUnfaveable() { +// t := suite.testTokens["local_account_1"] +// oauthToken := oauth.DBTokenToToken(t) + +// targetStatus := suite.testStatuses["local_account_2_status_3"] // this one is unlikeable and unreplyable + +// // setup +// recorder := httptest.NewRecorder() +// ctx, _ := testrig.CreateGinTestContext(recorder, nil) +// ctx.Set(oauth.SessionAuthorizedApplication, suite.testApplications["application_1"]) +// ctx.Set(oauth.SessionAuthorizedToken, oauthToken) +// ctx.Set(oauth.SessionAuthorizedUser, suite.testUsers["local_account_1"]) +// ctx.Set(oauth.SessionAuthorizedAccount, suite.testAccounts["local_account_1"]) +// ctx.Request = httptest.NewRequest(http.MethodPost, fmt.Sprintf("http://localhost:8080%s", strings.Replace(statuses.FavouritePath, ":id", targetStatus.ID, 1)), nil) // the endpoint we're hitting +// ctx.Request.Header.Set("accept", "application/json") + +// // normally the router would populate these params from the path values, +// // but because we're calling the function directly, we need to set them manually. +// ctx.Params = gin.Params{ +// gin.Param{ +// Key: statuses.IDKey, +// Value: targetStatus.ID, +// }, +// } + +// suite.statusModule.StatusFavePOSTHandler(ctx) + +// // check response +// suite.EqualValues(http.StatusForbidden, recorder.Code) + +// result := recorder.Result() +// defer result.Body.Close() +// b, err := ioutil.ReadAll(result.Body) +// assert.NoError(suite.T(), err) +// assert.Equal(suite.T(), `{"error":"Forbidden: status is not faveable"}`, string(b)) +// } func TestStatusFaveTestSuite(t *testing.T) { suite.Run(t, new(StatusFaveTestSuite)) |