newdrive/internal/transport/httpapi/server_test.go
Elijah f24e96efa7
All checks were successful
CI / Backend (push) Successful in 29s
CI / Frontend (push) Successful in 9m27s
CI / Contracts and repository policy (push) Successful in 7s
CI / Container (push) Successful in 18s
Harden CI and switch release builds to tagged immutable images
2026-07-15 19:21:07 -07:00

34 lines
760 B
Go

package httpapi
import (
"io"
"log/slog"
"net/http"
"net/http/httptest"
"strings"
"testing"
"drive.local/drivev2/internal/config"
)
func TestLiveHealth(t *testing.T) {
t.Parallel()
server := NewServer(
config.Config{HTTPAddress: ":0", WebRoot: t.TempDir()},
"test",
slog.New(slog.NewTextHandler(io.Discard, nil)),
http.NotFoundHandler(),
)
request := httptest.NewRequest(http.MethodGet, "/health/live", nil)
recorder := httptest.NewRecorder()
server.httpServer.Handler.ServeHTTP(recorder, request)
if recorder.Code != http.StatusOK {
t.Fatalf("status = %d, want %d", recorder.Code, http.StatusOK)
}
if !strings.Contains(recorder.Body.String(), `"status":"live"`) {
t.Fatalf("unexpected body: %s", recorder.Body.String())
}
}