- remove backend-old (Medusa), saveinmed-frontend (Next.js/Appwrite) and marketplace dirs - split Go usecases by domain and move notifications/payments to infrastructure - reorganize frontend pages into auth, dashboard and marketplace modules - add Makefile, docker-compose.yml and architecture docs
40 lines
1.1 KiB
Go
40 lines
1.1 KiB
Go
package notifications
|
|
|
|
import (
|
|
"bytes"
|
|
"context"
|
|
"log"
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/gofrs/uuid/v5"
|
|
"github.com/saveinmed/backend-go/internal/domain"
|
|
)
|
|
|
|
func TestLoggerNotificationService(t *testing.T) {
|
|
buffer := &bytes.Buffer{}
|
|
original := log.Writer()
|
|
log.SetOutput(buffer)
|
|
defer log.SetOutput(original)
|
|
|
|
svc := NewLoggerNotificationService()
|
|
ctx := context.Background()
|
|
order := &domain.Order{ID: uuid.Must(uuid.NewV7()), TotalCents: 12345, Status: domain.OrderStatusPaid}
|
|
buyer := &domain.User{Email: "buyer@example.com", Name: "Buyer"}
|
|
seller := &domain.User{Email: "seller@example.com", Name: "Seller"}
|
|
|
|
if err := svc.NotifyOrderCreated(ctx, order, buyer, seller); err != nil {
|
|
t.Fatalf("unexpected error: %v", err)
|
|
}
|
|
if err := svc.NotifyOrderStatusChanged(ctx, order, buyer); err != nil {
|
|
t.Fatalf("unexpected error: %v", err)
|
|
}
|
|
|
|
output := buffer.String()
|
|
if !strings.Contains(output, "Novo Pedido") {
|
|
t.Fatalf("expected output to include order created log, got %q", output)
|
|
}
|
|
if !strings.Contains(output, "Atualização do Pedido") {
|
|
t.Fatalf("expected output to include status change log, got %q", output)
|
|
}
|
|
}
|