package public

import (
	"testing"

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

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

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

	require.Equal(t, 1, publicRouteCounts(router)["GET /api/v1/public/config"])
	require.Equal(t, 1, publicRouteCounts(router)["POST /api/v1/public/content-reports"])
}

func publicRouteCounts(router *gin.Engine) map[string]int {
	counts := make(map[string]int)
	for _, route := range router.Routes() {
		counts[route.Method+" "+route.Path]++
	}
	return counts
}
