mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2026-01-07 11:53:16 -06:00
test undo announce
This commit is contained in:
parent
97d635d1dd
commit
ce2d5199c7
1 changed files with 56 additions and 0 deletions
|
|
@ -20,6 +20,7 @@ package workers_test
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
@ -29,6 +30,7 @@ import (
|
||||||
"github.com/superseriousbusiness/gotosocial/internal/ap"
|
"github.com/superseriousbusiness/gotosocial/internal/ap"
|
||||||
apimodel "github.com/superseriousbusiness/gotosocial/internal/api/model"
|
apimodel "github.com/superseriousbusiness/gotosocial/internal/api/model"
|
||||||
"github.com/superseriousbusiness/gotosocial/internal/db"
|
"github.com/superseriousbusiness/gotosocial/internal/db"
|
||||||
|
"github.com/superseriousbusiness/gotosocial/internal/gtscontext"
|
||||||
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
|
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
|
||||||
"github.com/superseriousbusiness/gotosocial/internal/messages"
|
"github.com/superseriousbusiness/gotosocial/internal/messages"
|
||||||
"github.com/superseriousbusiness/gotosocial/internal/stream"
|
"github.com/superseriousbusiness/gotosocial/internal/stream"
|
||||||
|
|
@ -679,6 +681,60 @@ func (suite *FromFediAPITestSuite) TestMoveAccount() {
|
||||||
suite.WithinDuration(time.Now(), move.SucceededAt, 1*time.Minute)
|
suite.WithinDuration(time.Now(), move.SucceededAt, 1*time.Minute)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (suite *FromFediAPITestSuite) TestUndoAnnounce() {
|
||||||
|
var (
|
||||||
|
ctx = context.Background()
|
||||||
|
testStructs = testrig.SetupTestStructs(rMediaPath, rTemplatePath)
|
||||||
|
requestingAcct = suite.testAccounts["remote_account_1"]
|
||||||
|
receivingAcct = suite.testAccounts["local_account_1"]
|
||||||
|
boostedStatus = suite.testStatuses["admin_account_status_1"]
|
||||||
|
)
|
||||||
|
defer testrig.TearDownTestStructs(testStructs)
|
||||||
|
|
||||||
|
// Have remote_account_1 boost admin_account.
|
||||||
|
boost, err := testStructs.TypeConverter.StatusToBoost(
|
||||||
|
ctx,
|
||||||
|
boostedStatus,
|
||||||
|
requestingAcct,
|
||||||
|
"",
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
suite.FailNow(err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set the boost URI + URL to
|
||||||
|
// fossbros-anonymous.io.
|
||||||
|
boost.URI = "https://fossbros-anonymous.io/users/foss_satan/" + boost.ID
|
||||||
|
boost.URL = boost.URI
|
||||||
|
|
||||||
|
// Store the boost.
|
||||||
|
if err := testStructs.State.DB.PutStatus(ctx, boost); err != nil {
|
||||||
|
suite.FailNow(err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
// Process the Undo.
|
||||||
|
err = testStructs.Processor.Workers().ProcessFromFediAPI(ctx, &messages.FromFediAPI{
|
||||||
|
APObjectType: ap.ActivityAnnounce,
|
||||||
|
APActivityType: ap.ActivityUndo,
|
||||||
|
GTSModel: boost,
|
||||||
|
Receiving: receivingAcct,
|
||||||
|
Requesting: requestingAcct,
|
||||||
|
})
|
||||||
|
suite.NoError(err)
|
||||||
|
|
||||||
|
// Wait for side effects to trigger:
|
||||||
|
// the boost should be deleted.
|
||||||
|
if !testrig.WaitFor(func() bool {
|
||||||
|
_, err := testStructs.State.DB.GetStatusByID(
|
||||||
|
gtscontext.SetBarebones(ctx),
|
||||||
|
boost.ID,
|
||||||
|
)
|
||||||
|
return errors.Is(err, db.ErrNoEntries)
|
||||||
|
}) {
|
||||||
|
suite.FailNow("timed out waiting for boost to be removed")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestFromFederatorTestSuite(t *testing.T) {
|
func TestFromFederatorTestSuite(t *testing.T) {
|
||||||
suite.Run(t, &FromFediAPITestSuite{})
|
suite.Run(t, &FromFediAPITestSuite{})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue