mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-23 14:55:42 +00:00
Feat(BE-36,37,38,39): master area, customer, kandang, location, warehouse
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
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))
|
||||
}
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user