feat: Update execution status after the creation of execution step
This commit is contained in:
@@ -68,10 +68,19 @@ class ExecutionStep extends Base {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async updateExecutionStatus() {
|
||||||
|
const execution = await this.$relatedQuery('execution');
|
||||||
|
|
||||||
|
await execution.$query().patch({
|
||||||
|
status: this.status === 'failure' ? 'failure' : 'success',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
async $afterInsert(queryContext) {
|
async $afterInsert(queryContext) {
|
||||||
await super.$afterInsert(queryContext);
|
await super.$afterInsert(queryContext);
|
||||||
Telemetry.executionStepCreated(this);
|
Telemetry.executionStepCreated(this);
|
||||||
await this.increaseUsageCount();
|
await this.increaseUsageCount();
|
||||||
|
await this.updateExecutionStatus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -149,4 +149,32 @@ describe('ExecutionStep model', () => {
|
|||||||
expect(increaseUsageCountSpy).toHaveBeenCalledOnce();
|
expect(increaseUsageCountSpy).toHaveBeenCalledOnce();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('updateExecutionStatus', () => {
|
||||||
|
it('should update execution status to failure when step status is failure', async () => {
|
||||||
|
const execution = await createExecution();
|
||||||
|
const executionStep = await createExecutionStep({
|
||||||
|
executionId: execution.id,
|
||||||
|
status: 'failure',
|
||||||
|
});
|
||||||
|
|
||||||
|
await executionStep.updateExecutionStatus();
|
||||||
|
|
||||||
|
const updatedExecution = await execution.$query();
|
||||||
|
expect(updatedExecution.status).toBe('failure');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should update execution status to success when step status is success', async () => {
|
||||||
|
const execution = await createExecution();
|
||||||
|
const executionStep = await createExecutionStep({
|
||||||
|
executionId: execution.id,
|
||||||
|
status: 'success',
|
||||||
|
});
|
||||||
|
|
||||||
|
await executionStep.updateExecutionStatus();
|
||||||
|
|
||||||
|
const updatedExecution = await execution.$query();
|
||||||
|
expect(updatedExecution.status).toBe('success');
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user