init push

This commit is contained in:
2026-07-16 22:16:45 +07:00
commit 8b068bdb10
1021 changed files with 332816 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
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))
}
}