[chore] make tests more cacheable by avoiding time.Now() (#656)

This commit is contained in:
tobi 2022-06-19 17:10:24 +02:00 committed by GitHub
commit 610395d5a5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 123 additions and 129 deletions

View file

@ -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() {
@ -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)

View file

@ -21,7 +21,6 @@ package dereferencing_test
import (
"context"
"testing"
"time"
"github.com/stretchr/testify/suite"
"github.com/superseriousbusiness/gotosocial/internal/ap"
@ -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)
}