Files
yhy-mager/backend/internal/httpapi/router_test.go
xiewenjun 54c318c615
Some checks failed
Check / delivery-static (push) Has been cancelled
Check / api (push) Has been cancelled
Check / web (push) Has been cancelled
feat: implement license platform business flows and delivery tooling
Add admin and customer interfaces, orders, signed activation and leases, protected package delivery, keyring verification, migrations, security controls, tests and deployment documentation.

Co-Authored-By: Craft Agent <agents-noreply@craft.do>
2026-10-09 15:33:22 +08:00

31 lines
763 B
Go

package httpapi
import (
"encoding/json"
"net/http"
"net/http/httptest"
"testing"
)
func TestLiveness(t *testing.T) {
w := httptest.NewRecorder()
NewRouter().ServeHTTP(w, httptest.NewRequest(http.MethodGet, "/api/v1/health/live", nil))
if w.Code != http.StatusOK {
t.Fatalf("status = %d, want 200", w.Code)
}
var body struct {
Status string `json:"status"`
}
if err := json.Unmarshal(w.Body.Bytes(), &body); err != nil || body.Status != "ok" {
t.Fatalf("body = %q, err = %v", w.Body.String(), err)
}
}
func TestUnknownRoute(t *testing.T) {
w := httptest.NewRecorder()
NewRouter().ServeHTTP(w, httptest.NewRequest(http.MethodGet, "/api/v1/licenses", nil))
if w.Code != http.StatusNotFound {
t.Fatalf("status = %d, want 404", w.Code)
}
}