1
0
forked from baron/baron-sso

userfront&backend test coverage 추가

This commit is contained in:
2026-05-29 18:04:04 +09:00
parent 23cd316c23
commit 4c56c28481
26 changed files with 2405 additions and 260 deletions

View File

@@ -58,6 +58,34 @@ func TestErrorWithDetailsResponseShape(t *testing.T) {
}
}
func TestErrorResponseShape(t *testing.T) {
app := fiber.New()
app.Get("/test", func(c *fiber.Ctx) error {
return Error(c, fiber.StatusUnauthorized, "invalid_session", "login required")
})
req := httptest.NewRequest(http.MethodGet, "/test", nil)
resp, err := app.Test(req)
if err != nil {
t.Fatalf("request failed: %v", err)
}
if resp.StatusCode != http.StatusUnauthorized {
t.Fatalf("unexpected status code: %d", resp.StatusCode)
}
body := parseBody(t, resp)
if body["error"] != "login required" {
t.Fatalf("unexpected error value: %v", body["error"])
}
if body["code"] != "invalid_session" {
t.Fatalf("unexpected code value: %v", body["code"])
}
if _, exists := body["details"]; exists {
t.Fatalf("details should be omitted when nil: %#v", body)
}
}
func TestStatusCodeMapping(t *testing.T) {
tests := []struct {
name string