package main

import (
	"strings"
	"testing"

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

func TestInternalAndExternalRoutersExposeSameAPIRoutes(t *testing.T) {
	external := newExternalRouter()
	internal := newInternalRouter()

	routeSet := func(routes gin.RoutesInfo) map[string]struct{} {
		result := make(map[string]struct{})
		for _, route := range routes {
			if strings.HasPrefix(route.Path, "/api/") || route.Path == "/loginCB" {
				result[route.Method+" "+route.Path] = struct{}{}
			}
		}
		return result
	}

	require.Equal(t, routeSet(external.Routes()), routeSet(internal.Routes()))
}
