micrach/gateway/controllers_test.go
Yanislav Igonin 642c1878cc
All checks were successful
CI / verify (push) Successful in 11m7s
feat: register with gateway via board token upsert
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-22 14:08:38 +04:00

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)
}
}