mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-20 13:31:56 +00:00
FIX[BE]: name duplicate flock,projectflock category change,menerapkan dto seperti warehouse di projectflock
This commit is contained in:
@@ -113,9 +113,6 @@ func TestProjectFlockSummary(t *testing.T) {
|
||||
if firstPivotRecord.KandangId != kandangID {
|
||||
t.Fatalf("expected pivot kandang id %d, got %d", kandangID, firstPivotRecord.KandangId)
|
||||
}
|
||||
if firstPivotRecord.DetachedAt != nil {
|
||||
t.Fatalf("expected pivot DetachedAt to be nil for active assignment, got %v", firstPivotRecord.DetachedAt)
|
||||
}
|
||||
|
||||
secondKandangID := createKandang(t, app, "Kandang Summary 2", locationID, 1)
|
||||
secondPayload := map[string]any{
|
||||
@@ -158,9 +155,6 @@ func TestProjectFlockSummary(t *testing.T) {
|
||||
if secondPivotRecord.KandangId != secondKandangID {
|
||||
t.Fatalf("expected second pivot kandang id %d, got %d", secondKandangID, secondPivotRecord.KandangId)
|
||||
}
|
||||
if secondPivotRecord.DetachedAt != nil {
|
||||
t.Fatalf("expected second pivot DetachedAt to be nil, got %v", secondPivotRecord.DetachedAt)
|
||||
}
|
||||
|
||||
secondKandang := fetchKandang(t, db, secondKandangID)
|
||||
if secondKandang.Status != string(utils.KandangStatusPengajuan) {
|
||||
@@ -198,15 +192,14 @@ func TestProjectFlockSummary(t *testing.T) {
|
||||
t.Fatalf("expected kandang status to revert to NON_ACTIVE, got %s", firstKandang.Status)
|
||||
}
|
||||
|
||||
var firstPivot entities.ProjectFlockKandang
|
||||
if err := db.First(&firstPivot, firstPivotRecord.Id).Error; err != nil {
|
||||
t.Fatalf("failed to reload first pivot record: %v", err)
|
||||
var remainingFirst int64
|
||||
if err := db.Model(&entities.ProjectFlockKandang{}).
|
||||
Where("project_flock_id = ? AND kandang_id = ?", createResp.Data.Id, kandangID).
|
||||
Count(&remainingFirst).Error; err != nil {
|
||||
t.Fatalf("failed to count first pivot records after delete: %v", err)
|
||||
}
|
||||
if firstPivot.DetachedAt == nil {
|
||||
t.Fatalf("expected first pivot DetachedAt to be set after delete")
|
||||
}
|
||||
if firstPivot.ProjectFlockId != createResp.Data.Id {
|
||||
t.Fatalf("expected first pivot project_flock_id %d, got %d", createResp.Data.Id, firstPivot.ProjectFlockId)
|
||||
if remainingFirst != 0 {
|
||||
t.Fatalf("expected no pivot records remaining after delete, found %d", remainingFirst)
|
||||
}
|
||||
|
||||
resp, body = doJSONRequest(t, app, http.MethodDelete, "/api/production/project_flocks/"+uintToString(createRespSecond.Data.Id), nil)
|
||||
@@ -222,15 +215,14 @@ func TestProjectFlockSummary(t *testing.T) {
|
||||
t.Fatalf("expected second kandang status to revert to NON_ACTIVE, got %s", secondKandang.Status)
|
||||
}
|
||||
|
||||
var secondPivot entities.ProjectFlockKandang
|
||||
if err := db.First(&secondPivot, secondPivotRecord.Id).Error; err != nil {
|
||||
t.Fatalf("failed to reload second pivot record: %v", err)
|
||||
var remainingSecond int64
|
||||
if err := db.Model(&entities.ProjectFlockKandang{}).
|
||||
Where("project_flock_id = ? AND kandang_id = ?", createRespSecond.Data.Id, secondKandangID).
|
||||
Count(&remainingSecond).Error; err != nil {
|
||||
t.Fatalf("failed to count second pivot records after delete: %v", err)
|
||||
}
|
||||
if secondPivot.DetachedAt == nil {
|
||||
t.Fatalf("expected second pivot DetachedAt to be set after delete")
|
||||
}
|
||||
if secondPivot.ProjectFlockId != createRespSecond.Data.Id {
|
||||
t.Fatalf("expected second pivot project_flock_id %d, got %d", createRespSecond.Data.Id, secondPivot.ProjectFlockId)
|
||||
if remainingSecond != 0 {
|
||||
t.Fatalf("expected no second pivot records remaining after delete, found %d", remainingSecond)
|
||||
}
|
||||
|
||||
resp, body = doJSONRequest(t, app, http.MethodGet, "/api/production/project_flocks/flocks/"+uintToString(flockID)+"/periods", nil)
|
||||
|
||||
Reference in New Issue
Block a user