package handlers import ( "io" "net/http" "strings" "testing" "github.com/gofiber/fiber/v2" ) func TestNewHealthHandler(t *testing.T) { h := NewHealthHandler() if h == nil { t.Fatalf("expected health handler instance") } } func TestHealthHandler_Handle(t *testing.T) { h := NewHealthHandler() app := fiber.New() app.Get("/health", h.Handle) req, _ := http.NewRequest(http.MethodGet, "/health", nil) resp, err := app.Test(req) if err != nil { t.Fatalf("app.Test: %v", err) } if resp.StatusCode != http.StatusOK { t.Fatalf("expected 200, got %d", resp.StatusCode) } body, _ := io.ReadAll(resp.Body) if !strings.Contains(string(body), `"type":"health"`) { t.Fatalf("expected health type in body, got %s", string(body)) } if !strings.Contains(string(body), `"status":"ok"`) { t.Fatalf("expected status ok in body, got %s", string(body)) } }