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>
31 lines
763 B
Go
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)
|
|
}
|
|
}
|