mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-20 05:21:57 +00:00
36 lines
970 B
Go
36 lines
970 B
Go
package test
|
|
|
|
import (
|
|
"net/http"
|
|
"testing"
|
|
|
|
"github.com/gofiber/fiber/v2"
|
|
)
|
|
|
|
func TestLocationIntegration(t *testing.T) {
|
|
app, _ := setupIntegrationApp(t)
|
|
|
|
t.Run("creating location without existing area fails", func(t *testing.T) {
|
|
resp, body := doJSONRequest(t, app, http.MethodPost, "/api/master-data/locations", map[string]any{
|
|
"name": "Loc A",
|
|
"address": "Address",
|
|
"area_id": 999, // non-existent
|
|
})
|
|
if resp.StatusCode != fiber.StatusNotFound {
|
|
t.Fatalf("expected 404, got %d: %s", resp.StatusCode, string(body))
|
|
}
|
|
})
|
|
|
|
t.Run("creating location succeeds", func(t *testing.T) {
|
|
areaID := createArea(t, app, "Area For Location")
|
|
resp, body := doJSONRequest(t, app, http.MethodPost, "/api/master-data/locations", map[string]any{
|
|
"name": "Location OK",
|
|
"address": "Addr",
|
|
"area_id": areaID,
|
|
})
|
|
if resp.StatusCode != fiber.StatusCreated {
|
|
t.Fatalf("expected 201, got %d: %s", resp.StatusCode, string(body))
|
|
}
|
|
})
|
|
}
|