From b6b0bd7ce79bf870a5855cdbe1b9e79c26461258 Mon Sep 17 00:00:00 2001 From: ewin Date: Wed, 5 Mar 2025 16:24:53 -0500 Subject: [PATCH] Update new tests to check content type on API statuses --- internal/processing/status/create_test.go | 12 +++--------- internal/processing/status/edit_test.go | 10 +++++++--- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/internal/processing/status/create_test.go b/internal/processing/status/create_test.go index e0fa67bb5..ec1ded3b0 100644 --- a/internal/processing/status/create_test.go +++ b/internal/processing/status/create_test.go @@ -263,15 +263,9 @@ func (suite *StatusCreateTestSuite) TestProcessNoContentTypeUsesDefault() { suite.Equal("

poopoo peepee

", apiStatus.Content) - // content type isn't actually returned when creating a - // status, so we have to fetch from the database to check - createdStatus, err := suite.state.DB.GetStatusByID(ctx, apiStatus.ID) - suite.NoError(err) - - // Check created status against requester's default content type - // setting (the test accounts don't actually have settings on them, - // so instead we check that the global default content type is used) - suite.Equal(gtsmodel.StatusContentTypeDefault, createdStatus.ContentType) + // the test accounts don't have settings, so we're comparing to + // the global default value instead of the requester's default + suite.Equal(apimodel.StatusContentTypeDefault, apiStatus.ContentType) } func TestStatusCreateTestSuite(t *testing.T) { diff --git a/internal/processing/status/edit_test.go b/internal/processing/status/edit_test.go index fa365db0b..b1fd07774 100644 --- a/internal/processing/status/edit_test.go +++ b/internal/processing/status/edit_test.go @@ -195,6 +195,11 @@ func (suite *StatusEditTestSuite) TestEditOnStatusWithNoContentType() { suite.Equal(form.Status, apiStatus.Text) suite.NotEqual(util.FormatISO8601(status.EditedAt), *apiStatus.EditedAt) + // Check response against requester's default content type setting + // (the test accounts don't actually have settings on them, so + // instead we check that the global default content type is used) + suite.Equal(apimodel.StatusContentTypeDefault, apiStatus.ContentType) + // Fetched the latest version of edited status from the database. latestStatus, err := suite.state.DB.GetStatusByID(ctx, status.ID) suite.NoError(err) @@ -206,9 +211,8 @@ func (suite *StatusEditTestSuite) TestEditOnStatusWithNoContentType() { suite.Equal(len(status.EditIDs)+1, len(latestStatus.EditIDs)) suite.NotEqual(status.UpdatedAt(), latestStatus.UpdatedAt()) - // Check latest status against requester's default content type - // setting (the test accounts don't actually have settings on them, - // so instead we check that the global default content type is used) + // Check latest status against requester's default content + // type (again, actually just checking for the global default) suite.Equal(gtsmodel.StatusContentTypeDefault, latestStatus.ContentType) // Populate all historical edits for this status.