- Remove backend Medusa.js (TypeScript) e substitui pelo backend Go (saveinmed-performance-core) - Corrige testes auth.test.ts: alinha paths de API (v1/ sem barra inicial) e campo access_token - Corrige GroupedProductCard.test.tsx: ajusta distância formatada (toFixed) e troca userEvent por fireEvent com fakeTimers - Corrige AuthContext.test.tsx: usa vi.hoisted() para mocks e corrige parênteses no waitFor Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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)
|
|
}
|
|
}
|