Files
homelab-frontend/internal/config/auth_required_test.go
T
Story Crater BotandClaude Opus 5 058f11cf2b
CI / Test (push) Canceled after 0s
CI / Vet (push) Canceled after 0s
CI / Build (push) Canceled after 0s
CI / Security (govulncheck) (push) Canceled after 0s
chore: initial commit of Go API gateway
Baseline for the Kong replacement on api.riotpiao.com. Brings the working
tree under version control for the first time: gateway source, the task
board that drives the agent runs, test fixtures, and K8s manifests.

Anchor the gateway ignore rule to the repo root. Unanchored, "gateway"
also matched the cmd/gateway/ source directory, so the program entrypoint
was excluded from every commit.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
2026-08-19 20:54:34 -07:00

25 lines
795 B
Go

package config_test
import (
"testing"
"github.com/Riotpiaole/homelab-frontend/internal/config"
)
// TestLoadRoutesMissingAuthRequired tests that the auth-required flag is not a silent default:
// if it is absent from YAML, startup must fail with a message naming the offending route and field.
func TestLoadRoutesMissingAuthRequired(t *testing.T) {
routes, err := config.LoadRoutesFromFile("../../testdata/config/missing-authRequired.yaml")
if err == nil {
t.Fatal("expected error for missing authRequired, got nil")
}
if routes != nil {
t.Error("expected nil routes on error")
}
want := "route \"test-route\": field 'authRequired' is required"
got := err.Error()
if got != want {
t.Fatalf("error did not name the offending route and field; want %q, got %q", want, got)
}
}