Files
jellybit/internal/httpapi/loglevel_internal_test.go
T

28 lines
898 B
Go

package httpapi
import (
"log/slog"
"net/http/httptest"
"testing"
)
func TestRequestLogLevel(t *testing.T) {
cases := []struct {
method, path string
want slog.Level
}{
{"GET", "/healthz", slog.LevelDebug}, // healthcheck — тихо
{"GET", "/", slog.LevelDebug}, // список (авто-рефреш)
{"GET", "/review/1", slog.LevelDebug}, // страница ревью
{"GET", "/api/downloads", slog.LevelInfo}, // REST API — на INFO
{"POST", "/ui/downloads/1/apply", slog.LevelInfo}, // мутация — на INFO
{"POST", "/api/downloads", slog.LevelInfo}, // приём — на INFO
}
for _, c := range cases {
r := httptest.NewRequest(c.method, c.path, nil)
if got := requestLogLevel(r); got != c.want {
t.Errorf("%s %s: level=%v, want %v", c.method, c.path, got, c.want)
}
}
}