mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-20 13:31:56 +00:00
37 lines
1.0 KiB
Go
37 lines
1.0 KiB
Go
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))
|
|
}
|
|
})
|
|
}
|