mirror of
https://github.com/yanislav-igonin/micrach
synced 2026-07-27 05:14:17 +03:00
All checks were successful
CI / verify (push) Successful in 11m7s
Co-authored-by: Cursor <cursoragent@cursor.com>
32 lines
660 B
Go
32 lines
660 B
Go
package gateway
|
|
|
|
import (
|
|
"encoding/json"
|
|
"net/http/httptest"
|
|
"testing"
|
|
|
|
"github.com/gofiber/fiber/v2"
|
|
)
|
|
|
|
func TestPingIsPublic(t *testing.T) {
|
|
app := fiber.New()
|
|
app.Get("/api/ping", Ping)
|
|
|
|
req := httptest.NewRequest("GET", "/api/ping", nil)
|
|
resp, err := app.Test(req)
|
|
if err != nil {
|
|
t.Fatalf("test ping request: %v", err)
|
|
}
|
|
if resp.StatusCode != fiber.StatusOK {
|
|
t.Fatalf("expected status %d, got %d", fiber.StatusOK, resp.StatusCode)
|
|
}
|
|
|
|
var body map[string]bool
|
|
if err := json.NewDecoder(resp.Body).Decode(&body); err != nil {
|
|
t.Fatalf("decode response: %v", err)
|
|
}
|
|
if !body["ok"] {
|
|
t.Fatalf("expected ok=true, got %+v", body)
|
|
}
|
|
}
|