package test import ( "net/http" "testing" "github.com/gofiber/fiber/v2" ) func TestKandangIntegration(t *testing.T) { app, _ := setupIntegrationApp(t) areaID := createArea(t, app, "Area Kandang") locationID := createLocation(t, app, "Location For Kandang", "Address", areaID) t.Run("create kandang success", func(t *testing.T) { resp, body := doJSONRequest(t, app, http.MethodPost, "/api/master-data/kandangs", map[string]any{ "name": "Kandang OK", "location_id": locationID, "pic_id": 1, }) if resp.StatusCode != fiber.StatusCreated { t.Fatalf("expected 201, got %d: %s", resp.StatusCode, string(body)) } }) t.Run("create kandang with unknown location fails", func(t *testing.T) { resp, body := doJSONRequest(t, app, http.MethodPost, "/api/master-data/kandangs", map[string]any{ "name": "Kandang Fail", "location_id": 999, "pic_id": 1, }) if resp.StatusCode != fiber.StatusNotFound { t.Fatalf("expected 404, got %d: %s", resp.StatusCode, string(body)) } }) }