package billing

import (
	"testing"

	"github.com/gin-gonic/gin"
	"github.com/stretchr/testify/require"

	"github.com/tidbcloud/AgentTeam/internal/api/testkit/httputil"
)

func TestRegisterRoutesOwnsBillingRoutes(t *testing.T) {
	t.Parallel()

	router := gin.New()
	RegisterRoutes(router, Dependencies{})

	counts := httputil.RouteCounts(router)
	for _, route := range []string{
		"GET /api/v1/billing/summary",
		"GET /api/v1/billing/ledger",
		"GET /api/v1/billing/payments",
		"GET /api/v1/billing/pricing",
		"POST /api/v1/billing/credit-recharge-orders",
		"GET /api/v1/billing/credit-recharge-orders/:orderId",
		"POST /api/v1/billing/credit-recharge-orders/:orderId/sync",
		"GET /api/v1/billing/seat-summary",
		"GET /api/v1/billing/seat-plans",
		"GET /api/v1/billing/seat-subscription",
		"GET /api/v1/billing/seat-orders",
		"POST /api/v1/billing/seat-orders",
		"GET /api/v1/billing/seat-orders/:orderId",
		"POST /api/v1/billing/seat-orders/:orderId/sync",
		"POST /api/v1/billing/seat-orders/:orderId/cancel",
		"GET /api/v1/billing/history",
		"POST /api/v1/billing/alipay/notify",
		"GET /api/v1/billing/alipay/return",
		"POST /api/v1/billing/seat-orders/alipay/notify",
		"GET /api/v1/billing/seat-orders/alipay/return",
	} {
		require.Equal(t, 1, counts[route], route)
	}
}

func TestRegisterRoutesIgnoresNilRouter(t *testing.T) {
	t.Parallel()

	require.NotPanics(t, func() {
		RegisterRoutes(nil, Dependencies{})
	})
}
