summaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2022-05-08 19:49:45 +0200
committerLibravatar GitHub <noreply@github.com>2022-05-08 18:49:45 +0100
commit5004e0a9da665ccc0e18cd4075ee636641b71f0a (patch)
treeb7c8269b954ced61afa9fffd7305bd88acca6f8e /internal
parent[bugfix] Fix existing bio text showing as HTML (#531) (diff)
downloadgotosocial-5004e0a9da665ccc0e18cd4075ee636641b71f0a.tar.xz
[bugfix] Fix remote media pruning failing if media already gone (#548)
* fix error check of prune to allow missing files * update go-store library, add test for pruning item with db entry but no file Signed-off-by: kim <grufwub@gmail.com> * remove now-unneccessary error check Signed-off-by: kim <grufwub@gmail.com> Co-authored-by: kim <grufwub@gmail.com>
Diffstat (limited to 'internal')
-rw-r--r--internal/api/client/auth/authorize_test.go6
-rw-r--r--internal/media/pruneremote_test.go19
2 files changed, 19 insertions, 6 deletions
diff --git a/internal/api/client/auth/authorize_test.go b/internal/api/client/auth/authorize_test.go
index 8f16702da..f9c1eceb6 100644
--- a/internal/api/client/auth/authorize_test.go
+++ b/internal/api/client/auth/authorize_test.go
@@ -7,7 +7,6 @@ import (
"testing"
"time"
- "codeberg.org/gruf/go-errors"
"github.com/gin-contrib/sessions"
"github.com/stretchr/testify/suite"
"github.com/superseriousbusiness/gotosocial/internal/api/client/auth"
@@ -26,8 +25,7 @@ type authorizeHandlerTestCase struct {
}
func (suite *AuthAuthorizeTestSuite) TestAccountAuthorizeHandler() {
-
- var tests = []authorizeHandlerTestCase{
+ tests := []authorizeHandlerTestCase{
{
description: "user has their email unconfirmed",
mutateUserAccount: func(user *gtsmodel.User, account *gtsmodel.Account) {
@@ -80,7 +78,7 @@ func (suite *AuthAuthorizeTestSuite) TestAccountAuthorizeHandler() {
testSession.Set(sessionUserID, user.ID)
testSession.Set(sessionClientID, suite.testApplications["application_1"].ClientID)
if err := testSession.Save(); err != nil {
- panic(errors.WrapMsgf(err, "failed on case: %s", testCase.description))
+ panic(fmt.Errorf("failed on case %s: %w", testCase.description, err))
}
testCase.mutateUserAccount(user, account)
diff --git a/internal/media/pruneremote_test.go b/internal/media/pruneremote_test.go
index f9d71cae2..9f3b65dd2 100644
--- a/internal/media/pruneremote_test.go
+++ b/internal/media/pruneremote_test.go
@@ -69,10 +69,8 @@ func (suite *PruneRemoteTestSuite) TestPruneAndRecache() {
// media should no longer be stored
_, err = suite.storage.Get(testAttachment.File.Path)
- suite.Error(err)
suite.ErrorIs(err, storage.ErrNotFound)
_, err = suite.storage.Get(testAttachment.Thumbnail.Path)
- suite.Error(err)
suite.ErrorIs(err, storage.ErrNotFound)
// now recache the image....
@@ -106,6 +104,23 @@ func (suite *PruneRemoteTestSuite) TestPruneAndRecache() {
suite.NoError(err)
}
+func (suite *PruneRemoteTestSuite) TestPruneOneNonExistent() {
+ ctx := context.Background()
+ testAttachment := suite.testAttachments["remote_account_1_status_1_attachment_1"]
+
+ // Delete this attachment cached on disk
+ media, err := suite.db.GetAttachmentByID(ctx, testAttachment.ID)
+ suite.NoError(err)
+ suite.True(media.Cached)
+ err = suite.storage.Delete(media.File.Path)
+ suite.NoError(err)
+
+ // Now attempt to prune remote for item with db entry no file
+ totalPruned, err := suite.manager.PruneRemote(ctx, 1)
+ suite.NoError(err)
+ suite.Equal(1, totalPruned)
+}
+
func TestPruneRemoteTestSuite(t *testing.T) {
suite.Run(t, &PruneRemoteTestSuite{})
}