chore: move notiffake to testutil (#13933)

This commit is contained in:
Marcin Tojek
2024-07-18 15:36:02 +02:00
committed by GitHub
parent fbd1d7f9a7
commit 91cbe679c0
3 changed files with 3 additions and 5 deletions
+37
View File
@@ -0,0 +1,37 @@
package testutil
import (
"context"
"sync"
"github.com/google/uuid"
)
type FakeNotificationEnqueuer struct {
mu sync.Mutex
Sent []*Notification
}
type Notification struct {
UserID, TemplateID uuid.UUID
Labels map[string]string
CreatedBy string
Targets []uuid.UUID
}
func (f *FakeNotificationEnqueuer) Enqueue(_ context.Context, userID, templateID uuid.UUID, labels map[string]string, createdBy string, targets ...uuid.UUID) (*uuid.UUID, error) {
f.mu.Lock()
defer f.mu.Unlock()
f.Sent = append(f.Sent, &Notification{
UserID: userID,
TemplateID: templateID,
Labels: labels,
CreatedBy: createdBy,
Targets: targets,
})
id := uuid.New()
return &id, nil
}