Files
affiliate_dash/backend/internal/router/router_test.go
T

50 lines
1.6 KiB
Go

package router
import (
"testing"
"affiliate_dash/internal/handler"
"affiliate_dash/internal/pkg/jwt"
"affiliate_dash/internal/service"
"affiliate_dash/internal/testdb"
"github.com/gin-gonic/gin"
)
func TestSetupDoesNotPanic(t *testing.T) {
gin.SetMode(gin.TestMode)
db := testdb.New(t)
codec, err := service.NewSecretCodec("test-master-key")
if err != nil {
t.Fatalf("codec: %v", err)
}
tenantSvc := service.NewTenantService(db)
authSvc := service.NewAuthService(db, jwt.NewManager("test-jwt"), tenantSvc)
userSvc := service.NewUserService(db, tenantSvc)
callbackSvc := service.NewCallbackService(db, codec)
fulfillmentSvc := service.NewFulfillmentService(db, callbackSvc)
merchantSvc := service.NewMerchantService(db, codec, tenantSvc)
deliverySvc := service.NewDeliveryService(fulfillmentSvc, "", "", "", "", 0)
defer func() {
if recovered := recover(); recovered != nil {
t.Fatalf("setup should not panic: %v", recovered)
}
}()
_ = Setup(&Handlers{
Auth: handler.NewAuthHandler(authSvc),
Dashboard: handler.NewDashboardHandler(fulfillmentSvc),
User: handler.NewUserHandler(userSvc),
Open: handler.NewOpenV1Handler(merchantSvc, fulfillmentSvc),
SourceOpen: handler.NewOpenHandler(fulfillmentSvc),
Merchant: handler.NewMerchantHandler(merchantSvc, fulfillmentSvc, callbackSvc, deliverySvc),
JWT: jwt.NewManager("test-jwt"),
Tenant: tenantSvc,
OpenDB: db,
SecretCodec: codec,
OpenAPIKey: "source-key",
OpenAPISecret: "source-secret",
OpenSignSkew: 300,
})
}