Signed-off-by: bnechyporenko <bnechyporenko@bol.com>
This commit is contained in:
bnechyporenko
2024-02-21 14:44:11 +01:00
parent 71f561b2cd
commit 81a3aa1ce6
2 changed files with 14 additions and 17 deletions
@@ -18,7 +18,7 @@ import { getVoidLogger } from '@backstage/backend-common';
import { NunjucksWorkflowRunner } from './NunjucksWorkflowRunner';
import { TemplateActionRegistry } from '../actions';
import { ScmIntegrations } from '@backstage/integration';
import { JsonValue } from '@backstage/types';
import { JsonObject } from '@backstage/types';
import { ConfigReader } from '@backstage/config';
import { TaskSpec } from '@backstage/plugin-scaffolder-common';
import {
@@ -580,26 +580,21 @@ describe('NunjucksWorkflowRunner', () => {
}),
getTaskState: (): Promise<
| {
state: {
[key: string]:
| { status: 'failed'; reason: string }
| {
status: 'success';
value: JsonValue;
};
};
state: JsonObject;
}
| undefined
> => {
return Promise.resolve({
state: {
['v1.task.checkpoint.key1']: {
status: 'success',
value: 'initial',
},
['v1.task.checkpoint.key2']: {
status: 'failed',
reason: 'fatal error',
checkpoints: {
['v1.task.checkpoint.key1']: {
status: 'success',
value: 'initial',
},
['v1.task.checkpoint.key2']: {
status: 'failed',
reason: 'fatal error',
},
},
},
});
@@ -368,7 +368,9 @@ export class NunjucksWorkflowRunner implements WorkflowRunner {
try {
let prevValue: U | undefined;
if (prevTaskState) {
const prevState = (prevTaskState.state as TaskState)?.[key];
const prevState = (
prevTaskState.state?.checkpoints as TaskState
)?.[key];
if (prevState && prevState.status === 'success') {
prevValue = prevState.value as U;
}