chore: send admin email on adding waitlist entry
This commit is contained in:
@@ -5,10 +5,13 @@ import (
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
pbaero "github.com/flowy-live/llink/genproto/aero"
|
||||
"github.com/flowy-live/llink/internal/testhelper"
|
||||
"github.com/flowy-live/llink/internal/waitlist"
|
||||
"github.com/flowy-live/llink/internal/waitlist/mocks"
|
||||
"github.com/jackc/pgx/v5/pgxpool"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"go.uber.org/mock/gomock"
|
||||
)
|
||||
|
||||
var dbPool *pgxpool.Pool
|
||||
@@ -21,9 +24,19 @@ func TestMain(m *testing.M) {
|
||||
os.Exit(ret)
|
||||
}
|
||||
|
||||
func newTestService(t *testing.T) waitlist.Service {
|
||||
ctrl := gomock.NewController(t)
|
||||
mockAero := mocks.NewMockPrimaryClient(ctrl)
|
||||
mockAero.EXPECT().
|
||||
ShootEmail(gomock.Any(), gomock.Any()).
|
||||
Return(&pbaero.ShootEmailResponse{}, nil).
|
||||
AnyTimes()
|
||||
return waitlist.NewService(dbPool, mockAero)
|
||||
}
|
||||
|
||||
func TestWaitlistService_AddAndGet(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
svc := waitlist.NewService(dbPool)
|
||||
svc := newTestService(t)
|
||||
|
||||
email := "[email protected]"
|
||||
metadata := map[string]string{"source": "landing-page", "plan": "pro"}
|
||||
@@ -48,7 +61,7 @@ func TestWaitlistService_AddAndGet(t *testing.T) {
|
||||
|
||||
func TestWaitlistService_AddDuplicate(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
svc := waitlist.NewService(dbPool)
|
||||
svc := newTestService(t)
|
||||
|
||||
email := "[email protected]"
|
||||
|
||||
@@ -66,7 +79,7 @@ func TestWaitlistService_AddDuplicate(t *testing.T) {
|
||||
|
||||
func TestWaitlistService_AddNilMetadata(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
svc := waitlist.NewService(dbPool)
|
||||
svc := newTestService(t)
|
||||
|
||||
email := "[email protected]"
|
||||
|
||||
@@ -84,7 +97,7 @@ func TestWaitlistService_AddNilMetadata(t *testing.T) {
|
||||
|
||||
func TestWaitlistService_GetEntryNotFound(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
svc := waitlist.NewService(dbPool)
|
||||
svc := newTestService(t)
|
||||
|
||||
_, err := svc.GetWaitlistEntryByEmail(ctx, "[email protected]")
|
||||
assert.ErrorIs(t, err, waitlist.EntryNotFoundError)
|
||||
@@ -92,7 +105,7 @@ func TestWaitlistService_GetEntryNotFound(t *testing.T) {
|
||||
|
||||
func TestWaitlistService_MarkInvited(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
svc := waitlist.NewService(dbPool)
|
||||
svc := newTestService(t)
|
||||
|
||||
email := "[email protected]"
|
||||
|
||||
@@ -115,7 +128,7 @@ func TestWaitlistService_MarkInvited(t *testing.T) {
|
||||
|
||||
func TestWaitlistService_MarkInvitedNotFound(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
svc := waitlist.NewService(dbPool)
|
||||
svc := newTestService(t)
|
||||
|
||||
err := svc.MarkWaitlistEntryInvited(ctx, "[email protected]")
|
||||
assert.ErrorIs(t, err, waitlist.EntryNotFoundError)
|
||||
@@ -123,7 +136,7 @@ func TestWaitlistService_MarkInvitedNotFound(t *testing.T) {
|
||||
|
||||
func TestWaitlistService_GetWaitlistFilters(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
svc := waitlist.NewService(dbPool)
|
||||
svc := newTestService(t)
|
||||
|
||||
uninvitedEmail := "[email protected]"
|
||||
invitedEmail := "[email protected]"
|
||||
@@ -166,7 +179,7 @@ func TestWaitlistService_GetWaitlistFilters(t *testing.T) {
|
||||
|
||||
func TestWaitlistService_EmailNormalization(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
svc := waitlist.NewService(dbPool)
|
||||
svc := newTestService(t)
|
||||
|
||||
// Add with uppercase email
|
||||
err := svc.AddToWaitlist(ctx, "[email protected]", nil)
|
||||
@@ -188,7 +201,7 @@ func TestWaitlistService_EmailNormalization(t *testing.T) {
|
||||
|
||||
func TestWaitlistService_InvalidEmail(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
svc := waitlist.NewService(dbPool)
|
||||
svc := newTestService(t)
|
||||
|
||||
err := svc.AddToWaitlist(ctx, "not-an-email", nil)
|
||||
assert.Error(t, err)
|
||||
|
||||
Reference in New Issue
Block a user