FIX[BE]: period and adjustment helper to function

This commit is contained in:
ragilap
2025-10-16 16:44:26 +07:00
parent 62a1011a4b
commit 8c0790627a
3 changed files with 18 additions and 1 deletions
+13 -1
View File
@@ -1,6 +1,7 @@
package test
import (
"encoding/json"
"net/http"
"testing"
@@ -17,13 +18,24 @@ func TestKandangIntegration(t *testing.T) {
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",
"status": "ACTIVE",
"location_id": locationID,
"pic_id": 1,
})
if resp.StatusCode != fiber.StatusCreated {
t.Fatalf("expected 201, got %d: %s", resp.StatusCode, string(body))
}
var createResp struct {
Data struct {
Status string `json:"status"`
} `json:"data"`
}
if err := json.Unmarshal(body, &createResp); err != nil {
t.Fatalf("failed to parse create response: %v", err)
}
if createResp.Data.Status == "" {
t.Fatalf("expected default status to be returned, got empty")
}
})
t.Run("create kandang with unknown location fails", func(t *testing.T) {