mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-21 05:45:44 +00:00
Feat(BE-36,37,38,39): finish master data management api
This commit is contained in:
@@ -24,7 +24,7 @@ func TestCustomerIntegration(t *testing.T) {
|
||||
"type": utils.CustomerSupplierTypeBisnis,
|
||||
"address": "Somewhere",
|
||||
"phone": "0800000000",
|
||||
"email": "invalid@example.com",
|
||||
"email": "Invalid@example.com",
|
||||
"account_number": "ACC-INVALID",
|
||||
})
|
||||
if resp.StatusCode != fiber.StatusNotFound {
|
||||
@@ -32,18 +32,18 @@ func TestCustomerIntegration(t *testing.T) {
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("creating customer with invalid type fails", func(t *testing.T) {
|
||||
t.Run("creating customer with Invalid type fails", func(t *testing.T) {
|
||||
resp, body := doJSONRequest(t, app, http.MethodPost, "/api/master-data/customers", map[string]any{
|
||||
"name": "Invalid Type",
|
||||
"pic_id": 1,
|
||||
"type": "UNKNOWN",
|
||||
"address": "Somewhere",
|
||||
"phone": "081234567891",
|
||||
"email": "invalid-type@example.com",
|
||||
"email": "Invalid-type@example.com",
|
||||
"account_number": "ACC-INVALID-TYPE",
|
||||
})
|
||||
if resp.StatusCode != fiber.StatusBadRequest {
|
||||
t.Fatalf("expected 400 when type is invalid, got %d: %s", resp.StatusCode, string(body))
|
||||
t.Fatalf("expected 400 when type is Invalid, got %d: %s", resp.StatusCode, string(body))
|
||||
}
|
||||
})
|
||||
|
||||
@@ -140,16 +140,16 @@ func TestCustomerIntegration(t *testing.T) {
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("updating customer with invalid type fails", func(t *testing.T) {
|
||||
t.Run("updating customer with Invalid type fails", func(t *testing.T) {
|
||||
resp, body := doJSONRequest(t, app, http.MethodPatch, fmt.Sprintf("/api/master-data/customers/%d", customerID), map[string]any{
|
||||
"type": "random-type",
|
||||
})
|
||||
if resp.StatusCode != fiber.StatusBadRequest {
|
||||
t.Fatalf("expected 400 when updating with invalid type, got %d: %s", resp.StatusCode, string(body))
|
||||
t.Fatalf("expected 400 when updating with Invalid type, got %d: %s", resp.StatusCode, string(body))
|
||||
}
|
||||
customer := fetchCustomer(t, db, customerID)
|
||||
if customer.Type != string(utils.CustomerSupplierTypeIndividual) {
|
||||
t.Fatalf("expected type to remain %q after invalid update, got %q", utils.CustomerSupplierTypeIndividual, customer.Type)
|
||||
t.Fatalf("expected type to remain %q after Invalid update, got %q", utils.CustomerSupplierTypeIndividual, customer.Type)
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user