saveinmed/backend/internal/usecase/payment_config_test.go
Gabbriiel 90467db1ec refactor: substitui backend Medusa por backend Go e corrige testes do marketplace
- 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>
2026-02-17 04:56:37 -06:00

53 lines
1.2 KiB
Go

package usecase
import (
"context"
"testing"
"github.com/gofrs/uuid/v5"
"github.com/saveinmed/backend-go/internal/domain"
)
func TestUpsertAndGetPaymentGatewayConfig(t *testing.T) {
svc, _ := newTestService()
ctx := context.Background()
config := &domain.PaymentGatewayConfig{
Provider: "stripe",
Active: true,
Credentials: "{\"secret\":\"secret\"}",
Environment: "sandbox",
Commission: 2.9,
}
if err := svc.UpsertPaymentGatewayConfig(ctx, config); err != nil {
t.Fatalf("unexpected error: %v", err)
}
stored, err := svc.GetPaymentGatewayConfig(ctx, "stripe")
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
if stored == nil || stored.Provider != "stripe" {
t.Fatal("expected stored config to be returned")
}
}
func TestOnboardSellerStoresAccount(t *testing.T) {
svc, repo := newTestService()
ctx := context.Background()
sellerID := uuid.Must(uuid.NewV7())
link, err := svc.OnboardSeller(ctx, sellerID, "stripe")
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
if link == "" {
t.Fatal("expected onboarding link")
}
stored, _ := repo.GetSellerPaymentAccount(ctx, sellerID)
if stored == nil || stored.Status != "pending" {
t.Fatal("expected seller payment account to be stored as pending")
}
}