func TestWorkItemHasBeenStored(t *testing.T) { workItem := models.WorkItem{ Action: "Ingest", Stage: "Record", Status: "Success", } assert.True(t, workItem.HasBeenStored()) workItem.Stage = constants.StageCleanup assert.True(t, workItem.HasBeenStored()) workItem.Stage = constants.StageStore workItem.Status = constants.StatusPending assert.True(t, workItem.HasBeenStored()) workItem.Stage = constants.StageStore workItem.Status = constants.StatusStarted assert.False(t, workItem.HasBeenStored()) workItem.Stage = constants.StageFetch assert.False(t, workItem.HasBeenStored()) workItem.Stage = constants.StageUnpack assert.False(t, workItem.HasBeenStored()) workItem.Stage = constants.StageValidate assert.False(t, workItem.HasBeenStored()) }
func TestWorkItemShouldTryIngest(t *testing.T) { workItem := models.WorkItem{ Action: "Ingest", Stage: "Receive", Status: "Pending", Retry: true, } // Test stages assert.True(t, workItem.ShouldTryIngest()) workItem.Stage = "Fetch" assert.True(t, workItem.ShouldTryIngest()) workItem.Stage = "Unpack" assert.True(t, workItem.ShouldTryIngest()) workItem.Stage = "Validate" assert.True(t, workItem.ShouldTryIngest()) workItem.Stage = "Record" assert.False(t, workItem.ShouldTryIngest()) // Test Store/Pending and Store/Started workItem.Stage = "Store" workItem.Status = "Started" assert.False(t, workItem.ShouldTryIngest()) workItem.Stage = "Store" workItem.Status = "Pending" assert.False(t, workItem.ShouldTryIngest()) // Test Retry = false workItem.Status = "Started" workItem.Retry = false workItem.Stage = "Receive" assert.False(t, workItem.ShouldTryIngest()) workItem.Stage = "Fetch" assert.False(t, workItem.ShouldTryIngest()) workItem.Stage = "Unpack" assert.False(t, workItem.ShouldTryIngest()) workItem.Stage = "Validate" assert.False(t, workItem.ShouldTryIngest()) workItem.Stage = "Record" assert.False(t, workItem.ShouldTryIngest()) }
func TestIsStoring(t *testing.T) { workItem := models.WorkItem{ Action: "Ingest", Stage: "Store", Status: "Started", } assert.True(t, workItem.IsStoring()) workItem.Status = "Pending" assert.False(t, workItem.IsStoring()) workItem.Status = "Started" workItem.Stage = "Record" assert.False(t, workItem.IsStoring()) }