Move webpush.MockSender and noopSender into testrig

This commit is contained in:
Vyr Cossont 2025-01-23 10:39:46 -08:00
commit b3aab4f0de
40 changed files with 66 additions and 128 deletions

View file

@ -50,7 +50,6 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/tracing"
"github.com/superseriousbusiness/gotosocial/internal/typeutils"
"github.com/superseriousbusiness/gotosocial/internal/web"
"github.com/superseriousbusiness/gotosocial/internal/webpush"
"github.com/superseriousbusiness/gotosocial/testrig"
)
@ -165,7 +164,7 @@ var Start action.GTSAction = func(ctx context.Context) error {
federator := testrig.NewTestFederator(state, transportController, mediaManager)
emailSender := testrig.NewEmailSender("./web/template/", nil)
webPushSender := webpush.NewMockSender()
webPushSender := testrig.NewWebPushMockSender()
typeConverter := typeutils.NewConverter(state)
filter := visibility.NewFilter(state)

View file

@ -38,7 +38,6 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/state"
"github.com/superseriousbusiness/gotosocial/internal/storage"
"github.com/superseriousbusiness/gotosocial/internal/typeutils"
"github.com/superseriousbusiness/gotosocial/internal/webpush"
"github.com/superseriousbusiness/gotosocial/testrig"
)
@ -93,7 +92,7 @@ func (suite *EmojiGetTestSuite) SetupTest() {
&suite.state,
suite.federator,
suite.emailSender,
webpush.NewNoopSender(),
testrig.NewNoopWebPushSender(),
suite.mediaManager,
)
suite.emojiModule = emoji.New(suite.processor)

View file

@ -33,7 +33,6 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/state"
"github.com/superseriousbusiness/gotosocial/internal/storage"
"github.com/superseriousbusiness/gotosocial/internal/typeutils"
"github.com/superseriousbusiness/gotosocial/internal/webpush"
"github.com/superseriousbusiness/gotosocial/testrig"
)
@ -105,7 +104,7 @@ func (suite *UserStandardTestSuite) SetupTest() {
&suite.state,
suite.federator,
suite.emailSender,
webpush.NewNoopSender(),
testrig.NewNoopWebPushSender(),
suite.mediaManager,
)
testrig.StartWorkers(&suite.state, suite.processor.Workers())

View file

@ -39,7 +39,6 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/processing"
"github.com/superseriousbusiness/gotosocial/internal/state"
"github.com/superseriousbusiness/gotosocial/internal/storage"
"github.com/superseriousbusiness/gotosocial/internal/webpush"
"github.com/superseriousbusiness/gotosocial/testrig"
)
@ -96,7 +95,7 @@ func (suite *AuthStandardTestSuite) SetupTest() {
&suite.state,
suite.federator,
suite.emailSender,
webpush.NewNoopSender(),
testrig.NewNoopWebPushSender(),
suite.mediaManager,
)
suite.authModule = auth.New(suite.db, suite.processor, suite.idp)

View file

@ -39,7 +39,6 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/state"
"github.com/superseriousbusiness/gotosocial/internal/storage"
"github.com/superseriousbusiness/gotosocial/internal/typeutils"
"github.com/superseriousbusiness/gotosocial/internal/webpush"
"github.com/superseriousbusiness/gotosocial/testrig"
)
@ -105,7 +104,7 @@ func (suite *AccountStandardTestSuite) SetupTest() {
&suite.state,
suite.federator,
suite.emailSender,
webpush.NewNoopSender(),
testrig.NewNoopWebPushSender(),
suite.mediaManager,
)
suite.accountsModule = accounts.New(suite.processor)

View file

@ -39,7 +39,6 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/state"
"github.com/superseriousbusiness/gotosocial/internal/storage"
"github.com/superseriousbusiness/gotosocial/internal/typeutils"
"github.com/superseriousbusiness/gotosocial/internal/webpush"
"github.com/superseriousbusiness/gotosocial/testrig"
)
@ -111,7 +110,7 @@ func (suite *AdminStandardTestSuite) SetupTest() {
&suite.state,
suite.federator,
suite.emailSender,
webpush.NewNoopSender(),
testrig.NewNoopWebPushSender(),
suite.mediaManager,
)
suite.adminModule = admin.New(&suite.state, suite.processor)

View file

@ -44,7 +44,6 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/state"
"github.com/superseriousbusiness/gotosocial/internal/storage"
"github.com/superseriousbusiness/gotosocial/internal/typeutils"
"github.com/superseriousbusiness/gotosocial/internal/webpush"
"github.com/superseriousbusiness/gotosocial/testrig"
)
@ -119,7 +118,7 @@ func (suite *BookmarkTestSuite) SetupTest() {
&suite.state,
suite.federator,
suite.emailSender,
webpush.NewNoopSender(),
testrig.NewNoopWebPushSender(),
suite.mediaManager,
)
suite.statusModule = statuses.New(suite.processor)

View file

@ -34,7 +34,6 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/oauth"
"github.com/superseriousbusiness/gotosocial/internal/state"
"github.com/superseriousbusiness/gotosocial/internal/typeutils"
"github.com/superseriousbusiness/gotosocial/internal/webpush"
"github.com/superseriousbusiness/gotosocial/testrig"
)
@ -96,7 +95,7 @@ func (suite *ExportsTestSuite) SetupTest() {
&suite.state,
federator,
testrig.NewEmailSender("../../../../web/template/", nil),
webpush.NewNoopSender(),
testrig.NewNoopWebPushSender(),
mediaManager,
)

View file

@ -31,7 +31,6 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/state"
"github.com/superseriousbusiness/gotosocial/internal/storage"
"github.com/superseriousbusiness/gotosocial/internal/typeutils"
"github.com/superseriousbusiness/gotosocial/internal/webpush"
"github.com/superseriousbusiness/gotosocial/testrig"
)
@ -103,7 +102,7 @@ func (suite *FavouritesStandardTestSuite) SetupTest() {
&suite.state,
suite.federator,
suite.emailSender,
webpush.NewNoopSender(),
testrig.NewNoopWebPushSender(),
suite.mediaManager,
)
suite.favModule = favourites.New(suite.processor)

View file

@ -37,7 +37,6 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/storage"
"github.com/superseriousbusiness/gotosocial/internal/stream"
"github.com/superseriousbusiness/gotosocial/internal/typeutils"
"github.com/superseriousbusiness/gotosocial/internal/webpush"
"github.com/superseriousbusiness/gotosocial/testrig"
)
@ -110,7 +109,7 @@ func (suite *FiltersTestSuite) SetupTest() {
&suite.state,
suite.federator,
suite.emailSender,
webpush.NewNoopSender(),
testrig.NewNoopWebPushSender(),
suite.mediaManager,
)
suite.filtersModule = filtersV1.New(suite.processor)

View file

@ -37,7 +37,6 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/storage"
"github.com/superseriousbusiness/gotosocial/internal/stream"
"github.com/superseriousbusiness/gotosocial/internal/typeutils"
"github.com/superseriousbusiness/gotosocial/internal/webpush"
"github.com/superseriousbusiness/gotosocial/testrig"
)
@ -109,7 +108,7 @@ func (suite *FiltersTestSuite) SetupTest() {
&suite.state,
suite.federator,
suite.emailSender,
webpush.NewNoopSender(),
testrig.NewNoopWebPushSender(),
suite.mediaManager,
)
suite.filtersModule = filtersV2.New(suite.processor)

View file

@ -32,7 +32,6 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/processing"
"github.com/superseriousbusiness/gotosocial/internal/state"
"github.com/superseriousbusiness/gotosocial/internal/storage"
"github.com/superseriousbusiness/gotosocial/internal/webpush"
"github.com/superseriousbusiness/gotosocial/testrig"
)
@ -93,7 +92,7 @@ func (suite *FollowedTagsTestSuite) SetupTest() {
&suite.state,
suite.federator,
suite.emailSender,
webpush.NewNoopSender(),
testrig.NewNoopWebPushSender(),
suite.mediaManager,
)
suite.followedTagsModule = followedtags.New(suite.processor)

View file

@ -38,7 +38,6 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/state"
"github.com/superseriousbusiness/gotosocial/internal/storage"
"github.com/superseriousbusiness/gotosocial/internal/typeutils"
"github.com/superseriousbusiness/gotosocial/internal/webpush"
"github.com/superseriousbusiness/gotosocial/testrig"
)
@ -101,7 +100,7 @@ func (suite *FollowRequestStandardTestSuite) SetupTest() {
&suite.state,
suite.federator,
suite.emailSender,
webpush.NewNoopSender(),
testrig.NewNoopWebPushSender(),
suite.mediaManager,
)
suite.followRequestModule = followrequests.New(suite.processor)

View file

@ -32,7 +32,6 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/oauth"
"github.com/superseriousbusiness/gotosocial/internal/state"
"github.com/superseriousbusiness/gotosocial/internal/typeutils"
"github.com/superseriousbusiness/gotosocial/internal/webpush"
"github.com/superseriousbusiness/gotosocial/testrig"
)
@ -93,7 +92,7 @@ func (suite *ImportTestSuite) SetupTest() {
&suite.state,
federator,
testrig.NewEmailSender("../../../../web/template/", nil),
webpush.NewNoopSender(),
testrig.NewNoopWebPushSender(),
mediaManager,
)
testrig.StartWorkers(&suite.state, processor.Workers())

View file

@ -38,7 +38,6 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/state"
"github.com/superseriousbusiness/gotosocial/internal/storage"
"github.com/superseriousbusiness/gotosocial/internal/typeutils"
"github.com/superseriousbusiness/gotosocial/internal/webpush"
"github.com/superseriousbusiness/gotosocial/testrig"
)
@ -104,7 +103,7 @@ func (suite *InstanceStandardTestSuite) SetupTest() {
&suite.state,
suite.federator,
suite.emailSender,
webpush.NewNoopSender(),
testrig.NewNoopWebPushSender(),
suite.mediaManager,
)
suite.instanceModule = instance.New(suite.processor)

View file

@ -31,7 +31,6 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/state"
"github.com/superseriousbusiness/gotosocial/internal/storage"
"github.com/superseriousbusiness/gotosocial/internal/typeutils"
"github.com/superseriousbusiness/gotosocial/internal/webpush"
"github.com/superseriousbusiness/gotosocial/testrig"
)
@ -104,7 +103,7 @@ func (suite *ListsStandardTestSuite) SetupTest() {
&suite.state,
suite.federator,
suite.emailSender,
webpush.NewNoopSender(),
testrig.NewNoopWebPushSender(),
suite.mediaManager,
)
suite.listsModule = lists.New(suite.processor)

View file

@ -44,7 +44,6 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/state"
"github.com/superseriousbusiness/gotosocial/internal/storage"
"github.com/superseriousbusiness/gotosocial/internal/typeutils"
"github.com/superseriousbusiness/gotosocial/internal/webpush"
"github.com/superseriousbusiness/gotosocial/testrig"
)
@ -109,7 +108,7 @@ func (suite *MediaCreateTestSuite) SetupTest() {
&suite.state,
suite.federator,
suite.emailSender,
webpush.NewNoopSender(),
testrig.NewNoopWebPushSender(),
suite.mediaManager,
)

View file

@ -42,7 +42,6 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/state"
"github.com/superseriousbusiness/gotosocial/internal/storage"
"github.com/superseriousbusiness/gotosocial/internal/typeutils"
"github.com/superseriousbusiness/gotosocial/internal/webpush"
"github.com/superseriousbusiness/gotosocial/testrig"
)
@ -107,7 +106,7 @@ func (suite *MediaUpdateTestSuite) SetupTest() {
&suite.state,
suite.federator,
suite.emailSender,
webpush.NewNoopSender(),
testrig.NewNoopWebPushSender(),
suite.mediaManager,
)

View file

@ -39,7 +39,6 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/state"
"github.com/superseriousbusiness/gotosocial/internal/storage"
"github.com/superseriousbusiness/gotosocial/internal/typeutils"
"github.com/superseriousbusiness/gotosocial/internal/webpush"
"github.com/superseriousbusiness/gotosocial/testrig"
)
@ -101,7 +100,7 @@ func (suite *MutesTestSuite) SetupTest() {
&suite.state,
suite.federator,
suite.emailSender,
webpush.NewNoopSender(),
testrig.NewNoopWebPushSender(),
suite.mediaManager,
)
suite.mutesModule = mutes.New(suite.processor)

View file

@ -31,7 +31,6 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/state"
"github.com/superseriousbusiness/gotosocial/internal/storage"
"github.com/superseriousbusiness/gotosocial/internal/typeutils"
"github.com/superseriousbusiness/gotosocial/internal/webpush"
"github.com/superseriousbusiness/gotosocial/testrig"
)
@ -105,7 +104,7 @@ func (suite *NotificationsTestSuite) SetupTest() {
&suite.state,
suite.federator,
suite.emailSender,
webpush.NewNoopSender(),
testrig.NewNoopWebPushSender(),
suite.mediaManager,
)
suite.notificationsModule = notifications.New(suite.processor)

View file

@ -31,7 +31,6 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/state"
"github.com/superseriousbusiness/gotosocial/internal/storage"
"github.com/superseriousbusiness/gotosocial/internal/typeutils"
"github.com/superseriousbusiness/gotosocial/internal/webpush"
"github.com/superseriousbusiness/gotosocial/testrig"
)
@ -44,7 +43,7 @@ type PollsStandardTestSuite struct {
processor *processing.Processor
emailSender email.Sender
sentEmails map[string]string
webPushSender *webpush.MockSender
webPushSender *testrig.WebPushMockSender
state state.State
// standard suite models
@ -97,7 +96,7 @@ func (suite *PollsStandardTestSuite) SetupTest() {
&suite.state,
suite.federator,
suite.emailSender,
webpush.NewNoopSender(),
testrig.NewNoopWebPushSender(),
suite.mediaManager,
)
suite.pollsModule = polls.New(suite.processor)

View file

@ -31,7 +31,6 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/processing"
"github.com/superseriousbusiness/gotosocial/internal/state"
"github.com/superseriousbusiness/gotosocial/internal/storage"
"github.com/superseriousbusiness/gotosocial/internal/webpush"
"github.com/superseriousbusiness/gotosocial/testrig"
)
@ -91,7 +90,7 @@ func (suite *PushTestSuite) SetupTest() {
&suite.state,
suite.federator,
suite.emailSender,
webpush.NewNoopSender(),
testrig.NewNoopWebPushSender(),
suite.mediaManager,
)
suite.pushModule = push.New(suite.processor)

View file

@ -31,7 +31,6 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/state"
"github.com/superseriousbusiness/gotosocial/internal/storage"
"github.com/superseriousbusiness/gotosocial/internal/typeutils"
"github.com/superseriousbusiness/gotosocial/internal/webpush"
"github.com/superseriousbusiness/gotosocial/testrig"
)
@ -96,7 +95,7 @@ func (suite *ReportsStandardTestSuite) SetupTest() {
&suite.state,
suite.federator,
suite.emailSender,
webpush.NewNoopSender(),
testrig.NewNoopWebPushSender(),
suite.mediaManager,
)
suite.reportsModule = reports.New(suite.processor)

View file

@ -38,7 +38,6 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/state"
"github.com/superseriousbusiness/gotosocial/internal/storage"
"github.com/superseriousbusiness/gotosocial/internal/typeutils"
"github.com/superseriousbusiness/gotosocial/internal/webpush"
"github.com/superseriousbusiness/gotosocial/testrig"
)
@ -100,7 +99,7 @@ func (suite *SearchStandardTestSuite) SetupTest() {
&suite.state,
suite.federator,
suite.emailSender,
webpush.NewNoopSender(),
testrig.NewNoopWebPushSender(),
suite.mediaManager,
)
suite.searchModule = search.New(suite.processor)

View file

@ -38,7 +38,6 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/state"
"github.com/superseriousbusiness/gotosocial/internal/storage"
"github.com/superseriousbusiness/gotosocial/internal/typeutils"
"github.com/superseriousbusiness/gotosocial/internal/webpush"
"github.com/superseriousbusiness/gotosocial/testrig"
)
@ -216,7 +215,7 @@ func (suite *StatusStandardTestSuite) SetupTest() {
&suite.state,
suite.federator,
suite.emailSender,
webpush.NewNoopSender(),
testrig.NewNoopWebPushSender(),
suite.mediaManager,
)
suite.statusModule = statuses.New(suite.processor)

View file

@ -44,7 +44,6 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/state"
"github.com/superseriousbusiness/gotosocial/internal/storage"
"github.com/superseriousbusiness/gotosocial/internal/typeutils"
"github.com/superseriousbusiness/gotosocial/internal/webpush"
"github.com/superseriousbusiness/gotosocial/testrig"
)
@ -116,7 +115,7 @@ func (suite *StreamingTestSuite) SetupTest() {
&suite.state,
suite.federator,
suite.emailSender,
webpush.NewNoopSender(),
testrig.NewNoopWebPushSender(),
suite.mediaManager,
)
suite.streamingModule = streaming.New(suite.processor, 1, 4096)

View file

@ -40,7 +40,6 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/processing"
"github.com/superseriousbusiness/gotosocial/internal/state"
"github.com/superseriousbusiness/gotosocial/internal/storage"
"github.com/superseriousbusiness/gotosocial/internal/webpush"
"github.com/superseriousbusiness/gotosocial/testrig"
)
@ -101,7 +100,7 @@ func (suite *TagsTestSuite) SetupTest() {
&suite.state,
suite.federator,
suite.emailSender,
webpush.NewNoopSender(),
testrig.NewNoopWebPushSender(),
suite.mediaManager,
)
suite.tagsModule = tags.New(suite.processor)

View file

@ -27,7 +27,6 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/api/client/user"
apimodel "github.com/superseriousbusiness/gotosocial/internal/api/model"
"github.com/superseriousbusiness/gotosocial/internal/state"
"github.com/superseriousbusiness/gotosocial/internal/webpush"
"github.com/superseriousbusiness/gotosocial/testrig"
)
@ -45,7 +44,7 @@ func (suite *EmailChangeTestSuite) TestEmailChangePOST() {
storage := testrig.NewInMemoryStorage()
sentEmails := make(map[string]string)
emailSender := testrig.NewEmailSender("../../../../web/template/", sentEmails)
webPushSender := webpush.NewNoopSender()
webPushSender := testrig.NewNoopWebPushSender()
processor := testrig.NewTestProcessor(state, suite.federator, emailSender, webPushSender, suite.mediaManager)
testrig.StartWorkers(state, processor.Workers())
userModule := user.New(processor)

View file

@ -36,7 +36,6 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/state"
"github.com/superseriousbusiness/gotosocial/internal/storage"
"github.com/superseriousbusiness/gotosocial/internal/typeutils"
"github.com/superseriousbusiness/gotosocial/internal/webpush"
"github.com/superseriousbusiness/gotosocial/testrig"
)
@ -99,7 +98,7 @@ func (suite *UserStandardTestSuite) SetupTest() {
&suite.state,
suite.federator,
testrig.NewEmailSender("../../../../web/template/", nil),
webpush.NewNoopSender(),
testrig.NewNoopWebPushSender(),
suite.mediaManager,
)
suite.userModule = user.New(suite.processor)

View file

@ -33,7 +33,6 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/state"
"github.com/superseriousbusiness/gotosocial/internal/storage"
"github.com/superseriousbusiness/gotosocial/internal/typeutils"
"github.com/superseriousbusiness/gotosocial/internal/webpush"
"github.com/superseriousbusiness/gotosocial/testrig"
)
@ -88,7 +87,7 @@ func (suite *FileserverTestSuite) SetupSuite() {
&suite.state,
suite.federator,
suite.emailSender,
webpush.NewNoopSender(),
testrig.NewNoopWebPushSender(),
suite.mediaManager,
)

View file

@ -32,7 +32,6 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/state"
"github.com/superseriousbusiness/gotosocial/internal/storage"
"github.com/superseriousbusiness/gotosocial/internal/typeutils"
"github.com/superseriousbusiness/gotosocial/internal/webpush"
"github.com/superseriousbusiness/gotosocial/testrig"
)
@ -99,7 +98,7 @@ func (suite *WebfingerStandardTestSuite) SetupTest() {
&suite.state,
suite.federator,
suite.emailSender,
webpush.NewNoopSender(),
testrig.NewNoopWebPushSender(),
suite.mediaManager,
)
suite.webfingerModule = webfinger.New(suite.processor)

View file

@ -40,7 +40,6 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
"github.com/superseriousbusiness/gotosocial/internal/processing"
"github.com/superseriousbusiness/gotosocial/internal/subscriptions"
"github.com/superseriousbusiness/gotosocial/internal/webpush"
"github.com/superseriousbusiness/gotosocial/testrig"
)
@ -99,7 +98,7 @@ func (suite *WebfingerGetTestSuite) funkifyAccountDomain(host string, accountDom
testrig.NewTestMediaManager(&suite.state),
&suite.state,
suite.emailSender,
webpush.NewNoopSender(),
testrig.NewNoopWebPushSender(),
visibility.NewFilter(&suite.state),
interaction.NewFilter(&suite.state),
)

View file

@ -37,7 +37,6 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/subscriptions"
"github.com/superseriousbusiness/gotosocial/internal/transport"
"github.com/superseriousbusiness/gotosocial/internal/typeutils"
"github.com/superseriousbusiness/gotosocial/internal/webpush"
"github.com/superseriousbusiness/gotosocial/testrig"
)
@ -120,7 +119,7 @@ func (suite *AdminStandardTestSuite) SetupTest() {
suite.mediaManager,
&suite.state,
suite.emailSender,
webpush.NewNoopSender(),
testrig.NewNoopWebPushSender(),
visibility.NewFilter(&suite.state),
interaction.NewFilter(&suite.state),
)

View file

@ -38,7 +38,6 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/subscriptions"
"github.com/superseriousbusiness/gotosocial/internal/transport"
"github.com/superseriousbusiness/gotosocial/internal/typeutils"
"github.com/superseriousbusiness/gotosocial/internal/webpush"
"github.com/superseriousbusiness/gotosocial/testrig"
)
@ -136,7 +135,7 @@ func (suite *ProcessingStandardTestSuite) SetupTest() {
suite.mediaManager,
&suite.state,
suite.emailSender,
webpush.NewNoopSender(),
testrig.NewNoopWebPushSender(),
visibility.NewFilter(&suite.state),
interaction.NewFilter(&suite.state),
)

View file

@ -36,7 +36,6 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/stream"
"github.com/superseriousbusiness/gotosocial/internal/typeutils"
"github.com/superseriousbusiness/gotosocial/internal/util"
"github.com/superseriousbusiness/gotosocial/internal/webpush"
"github.com/superseriousbusiness/gotosocial/testrig"
)
@ -182,7 +181,7 @@ func (suite *FromClientAPITestSuite) checkStreamed(
// checkWebPushed asserts that the target account got a single Web Push notification with a given type.
func (suite *FromClientAPITestSuite) checkWebPushed(
sender *webpush.MockSender,
sender *testrig.WebPushMockSender,
accountID string,
notificationType gtsmodel.NotificationType,
) {
@ -195,7 +194,7 @@ func (suite *FromClientAPITestSuite) checkWebPushed(
// checkNotWebPushed asserts that the target account got no Web Push notifications.
func (suite *FromClientAPITestSuite) checkNotWebPushed(
sender *webpush.MockSender,
sender *testrig.WebPushMockSender,
accountID string,
) {
pushedNotifications := sender.Sent[accountID]

View file

@ -33,7 +33,6 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/storage"
"github.com/superseriousbusiness/gotosocial/internal/transport"
"github.com/superseriousbusiness/gotosocial/internal/typeutils"
"github.com/superseriousbusiness/gotosocial/internal/webpush"
"github.com/superseriousbusiness/gotosocial/testrig"
)
@ -94,7 +93,7 @@ func (suite *TransportTestSuite) SetupTest() {
&suite.state,
suite.federator,
suite.emailSender,
webpush.NewNoopSender(),
testrig.NewNoopWebPushSender(),
suite.mediaManager,
)

View file

@ -27,7 +27,6 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/processing"
"github.com/superseriousbusiness/gotosocial/internal/state"
"github.com/superseriousbusiness/gotosocial/internal/typeutils"
"github.com/superseriousbusiness/gotosocial/internal/webpush"
"github.com/superseriousbusiness/gotosocial/testrig"
)
@ -541,7 +540,7 @@ func (suite *TypeUtilsTestSuite) GetProcessor() *processing.Processor {
mediaManager := testrig.NewTestMediaManager(&suite.state)
federator := testrig.NewTestFederator(&suite.state, transportController, mediaManager)
emailSender := testrig.NewEmailSender("../../web/template/", nil)
webPushSender := webpush.NewNoopSender()
webPushSender := testrig.NewNoopWebPushSender()
processor := testrig.NewTestProcessor(&suite.state, federator, emailSender, webPushSender, mediaManager)
testrig.StartWorkers(&suite.state, processor.Workers())

View file

@ -1,42 +0,0 @@
// GoToSocial
// Copyright (C) GoToSocial Authors admin@gotosocial.org
// SPDX-License-Identifier: AGPL-3.0-or-later
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package webpush
import (
"context"
"github.com/superseriousbusiness/gotosocial/internal/filter/usermute"
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
)
// noopSender drops anything sent to it.
// This should only be used in tests.
type noopSender struct{}
func NewNoopSender() Sender {
return &noopSender{}
}
func (n *noopSender) Send(
ctx context.Context,
notification *gtsmodel.Notification,
filters []*gtsmodel.Filter,
mutes *usermute.CompiledUserMuteList,
) error {
return nil
}

View file

@ -29,7 +29,6 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/subscriptions"
"github.com/superseriousbusiness/gotosocial/internal/transport"
"github.com/superseriousbusiness/gotosocial/internal/typeutils"
"github.com/superseriousbusiness/gotosocial/internal/webpush"
)
// TestStructs encapsulates structs needed to
@ -48,7 +47,7 @@ type TestStructs struct {
HTTPClient *MockHTTPClient
TypeConverter *typeutils.Converter
EmailSender email.Sender
WebPushSender *webpush.MockSender
WebPushSender *WebPushMockSender
TransportController transport.Controller
}
@ -85,7 +84,7 @@ func SetupTestStructs(
federator := NewTestFederator(&state, transportController, mediaManager)
oauthServer := NewTestOauthServer(db)
emailSender := NewEmailSender(rTemplatePath, nil)
webPushSender := webpush.NewMockSender()
webPushSender := NewWebPushMockSender()
common := common.New(
&state,

View file

@ -15,28 +15,29 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package webpush
package testrig
import (
"context"
"github.com/superseriousbusiness/gotosocial/internal/filter/usermute"
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
"github.com/superseriousbusiness/gotosocial/internal/webpush"
)
// MockSender collects a map of notifications sent to each account ID.
// This should only be used in tests.
type MockSender struct {
// WebPushMockSender collects a map of notifications sent to each account ID.
type WebPushMockSender struct {
Sent map[string][]*gtsmodel.Notification
}
func NewMockSender() *MockSender {
return &MockSender{
// NewWebPushMockSender creates a mock sender that can record sent Web Push notifications for test expectations.
func NewWebPushMockSender() *WebPushMockSender {
return &WebPushMockSender{
Sent: map[string][]*gtsmodel.Notification{},
}
}
func (m *MockSender) Send(
func (m *WebPushMockSender) Send(
ctx context.Context,
notification *gtsmodel.Notification,
filters []*gtsmodel.Filter,
@ -45,3 +46,20 @@ func (m *MockSender) Send(
m.Sent[notification.TargetAccountID] = append(m.Sent[notification.TargetAccountID], notification)
return nil
}
// noopSender drops anything sent to it.
type noopWebPushSender struct{}
// NewNoopWebPushSender creates a no-op sender that does nothing.
func NewNoopWebPushSender() webpush.Sender {
return &noopWebPushSender{}
}
func (n *noopWebPushSender) Send(
ctx context.Context,
notification *gtsmodel.Notification,
filters []*gtsmodel.Filter,
mutes *usermute.CompiledUserMuteList,
) error {
return nil
}