Skip to content

Commit

Permalink
[chore] make tests more cacheable by avoiding time.Now() (#656)
Browse files Browse the repository at this point in the history
  • Loading branch information
tsmethurst authored Jun 19, 2022
1 parent f42d5d8 commit 610395d
Show file tree
Hide file tree
Showing 3 changed files with 123 additions and 129 deletions.
4 changes: 2 additions & 2 deletions internal/api/client/admin/mediacleanup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func (suite *MediaCleanupTestSuite) TestMediaCleanupNoArg() {
suite.NoError(err)

// the media should no longer be cached
suite.True(prunedAttachment.Cached)
suite.False(prunedAttachment.Cached)
}

func (suite *MediaCleanupTestSuite) TestMediaCleanupNotOldEnough() {
Expand All @@ -90,7 +90,7 @@ func (suite *MediaCleanupTestSuite) TestMediaCleanupNotOldEnough() {

// set up the request
recorder := httptest.NewRecorder()
ctx := suite.newContext(recorder, http.MethodPost, []byte("{\"remote_cache_days\": 3}"), admin.EmojiPath, "application/json")
ctx := suite.newContext(recorder, http.MethodPost, []byte("{\"remote_cache_days\": 10000}"), admin.EmojiPath, "application/json")

// call the handler
suite.adminModule.MediaCleanupPOSTHandler(ctx)
Expand Down
3 changes: 0 additions & 3 deletions internal/federation/dereferencing/status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ package dereferencing_test
import (
"context"
"testing"
"time"

"github.com/stretchr/testify/suite"
"github.com/superseriousbusiness/gotosocial/internal/ap"
Expand Down Expand Up @@ -122,8 +121,6 @@ func (suite *StatusTestSuite) TestDereferenceStatusWithMention() {
suite.Equal(account.ID, m.OriginAccountID)
suite.Equal(fetchingAccount.ID, m.TargetAccountID)
suite.Equal(account.URI, m.OriginAccountURI)
suite.WithinDuration(time.Now(), m.CreatedAt, 5*time.Minute)
suite.WithinDuration(time.Now(), m.UpdatedAt, 5*time.Minute)
suite.False(m.Silent)
}

Expand Down
Loading

0 comments on commit 610395d

Please sign in to comment.