mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-20 05:21:57 +00:00
28 lines
744 B
Go
28 lines
744 B
Go
package test
|
|
|
|
import (
|
|
"net/http"
|
|
"testing"
|
|
|
|
"github.com/gofiber/fiber/v2"
|
|
)
|
|
|
|
func TestAreaIntegration(t *testing.T) {
|
|
app, db := setupIntegrationApp(t)
|
|
|
|
t.Run("create area trims name", func(t *testing.T) {
|
|
areaID := createArea(t, app, " Area Trim ")
|
|
if got := fetchAreaName(t, db, areaID); got != "Area Trim" {
|
|
t.Fatalf("expected trimmed name, got %q", got)
|
|
}
|
|
})
|
|
|
|
t.Run("duplicate area returns conflict", func(t *testing.T) {
|
|
createArea(t, app, "Duplicate Area")
|
|
resp, body := doJSONRequest(t, app, http.MethodPost, "/api/master-data/areas", map[string]any{"name": "Duplicate Area"})
|
|
if resp.StatusCode != fiber.StatusConflict {
|
|
t.Fatalf("expected 409 conflict, got %d: %s", resp.StatusCode, string(body))
|
|
}
|
|
})
|
|
}
|