feat(t237): import freight orders synchronously
This commit is contained in:
@@ -405,7 +405,9 @@ func TestAdminFreightAPIImportsAllItemsWithoutPII(t *testing.T) {
|
||||
),
|
||||
"freight-sync-1",
|
||||
)
|
||||
if create.Code != http.StatusAccepted {
|
||||
if create.Code != http.StatusCreated ||
|
||||
create.Header().Get("Location") != "/api/v1/freight-orders" ||
|
||||
!strings.Contains(create.Body.String(), `"status":"SUCCEEDED"`) {
|
||||
t.Fatalf("create status/body = %d / %s", create.Code, create.Body)
|
||||
}
|
||||
var createBody struct {
|
||||
@@ -486,8 +488,9 @@ func TestAdminFreightAPIImportsAllItemsWithoutPII(t *testing.T) {
|
||||
),
|
||||
"freight-sync-1",
|
||||
)
|
||||
if replay.Code != http.StatusAccepted ||
|
||||
if replay.Code != http.StatusOK ||
|
||||
!strings.Contains(replay.Body.String(), `"replayed":true`) ||
|
||||
!strings.Contains(replay.Body.String(), `"status":"SUCCEEDED"`) ||
|
||||
!strings.Contains(replay.Body.String(), createBody.Sync.ID) {
|
||||
t.Fatalf("replay status/body = %d / %s", replay.Code, replay.Body)
|
||||
}
|
||||
@@ -515,6 +518,9 @@ func TestAdminFreightDateSyncAdvancesInspectableWatermark(t *testing.T) {
|
||||
"freight-date-sync-1",
|
||||
)
|
||||
requireAdminStatus(t, create, http.StatusAccepted)
|
||||
if !strings.Contains(create.Body.String(), `"status":"PENDING"`) {
|
||||
t.Fatalf("date sync create response = %s", create.Body)
|
||||
}
|
||||
var created struct {
|
||||
Sync struct {
|
||||
ID string `json:"id"`
|
||||
@@ -589,31 +595,9 @@ func TestAdminProcurementAPIProducesImmutablePendingTask(t *testing.T) {
|
||||
),
|
||||
"procurement-freight-sync",
|
||||
)
|
||||
var syncBody struct {
|
||||
Sync struct {
|
||||
ID string `json:"id"`
|
||||
} `json:"sync"`
|
||||
}
|
||||
decodeResponse(t, createSync, &syncBody)
|
||||
succeeded := false
|
||||
for attempt := 0; attempt < 50; attempt++ {
|
||||
status := performAdminRequest(
|
||||
t,
|
||||
fixture.router,
|
||||
http.MethodGet,
|
||||
"/api/v1/freight-syncs/"+syncBody.Sync.ID,
|
||||
"",
|
||||
nil,
|
||||
"",
|
||||
)
|
||||
if strings.Contains(status.Body.String(), `"status":"SUCCEEDED"`) {
|
||||
succeeded = true
|
||||
break
|
||||
}
|
||||
time.Sleep(10 * time.Millisecond)
|
||||
}
|
||||
if !succeeded {
|
||||
t.Fatal("freight sync did not succeed")
|
||||
requireAdminStatus(t, createSync, http.StatusCreated)
|
||||
if !strings.Contains(createSync.Body.String(), `"status":"SUCCEEDED"`) {
|
||||
t.Fatalf("freight sync response = %s", createSync.Body)
|
||||
}
|
||||
orders := performAdminRequest(
|
||||
t,
|
||||
|
||||
Reference in New Issue
Block a user