package globalapi

import (
	"net/http"
	"testing"

	"github.com/stretchr/testify/assert"
)

func TestRouteOpsServer_RegistersOpsServerRoutes(t *testing.T) {
	registered := make(map[string]struct{})
	for _, route := range testEngine.Routes() {
		registered[route.Method+" "+route.Path] = struct{}{}
	}

	expectedRoutes := []string{
		http.MethodPost + " /ops/api/v1/vmclusters",
		http.MethodGet + " /ops/api/v1/vmclusters",
		http.MethodGet + " /ops/api/v1/vmclusters/:vmclusterId",
		http.MethodPut + " /ops/api/v1/vmclusters/:vmclusterId",
		http.MethodDelete + " /ops/api/v1/vmclusters/:vmclusterId",
		http.MethodPost + " /ops/api/v1/helmreleases",
		http.MethodGet + " /ops/api/v1/helmreleases",
		http.MethodPost + " /ops/api/v1/helmreleases/diff",
		http.MethodGet + " /ops/api/v1/helmreleases/:name",
		http.MethodPut + " /ops/api/v1/helmreleases/:name",
		http.MethodDelete + " /ops/api/v1/helmreleases/:name",
		http.MethodPost + " /ops/api/v1/upgradeOperations",
		http.MethodPost + " /ops/api/v1/upgradeOperations/dry-run",
		http.MethodGet + " /ops/api/v1/upgradeOperations",
		http.MethodGet + " /ops/api/v1/upgradeOperations/:id",
		http.MethodPut + " /ops/api/v1/upgradeOperations/:id/pause",
		http.MethodPut + " /ops/api/v1/upgradeOperations/:id/resume",
		http.MethodDelete + " /ops/api/v1/upgradeOperations/:id",
		http.MethodGet + " /ops/api/v1/nodeGroups",
		http.MethodGet + " /ops/api/v1/addons",
		http.MethodPut + " /ops/api/v1/alert-auth",
	}

	for _, expected := range expectedRoutes {
		_, ok := registered[expected]
		assert.True(t, ok, "route should be registered: %s", expected)
	}
}
