+ unit test

Signed-off-by: bnechyporenko <bnechyporenko@bol.com>
This commit is contained in:
bnechyporenko
2024-02-13 10:31:33 +01:00
parent 4d01452a88
commit 9c7e28a36e
7 changed files with 32 additions and 7 deletions
-1
View File
@@ -76,7 +76,6 @@
"@backstage/repo-tools": "workspace:*",
"@changesets/cli": "^2.14.0",
"@octokit/rest": "^19.0.3",
"@playwright/test": "^1.32.3",
"@spotify/eslint-plugin": "^14.1.3",
"@spotify/prettier-config": "^14.0.0",
"@techdocs/cli": "workspace:*",
+2 -2
View File
@@ -445,7 +445,7 @@ export class DatabaseTaskStore implements TaskStore {
ids: string[];
}>;
// (undocumented)
saveCheckpoint(options: {
saveTaskState(options: {
taskId: string;
state?:
| {
@@ -661,7 +661,7 @@ export interface TaskStore {
ids: string[];
}>;
// (undocumented)
saveCheckpoint?(options: {
saveTaskState?(options: {
taskId: string;
state?: {
[key: string]:
@@ -188,4 +188,31 @@ describe('DatabaseTaskStore', () => {
await store.shutdownTask({ taskId });
}).rejects.toThrow(ConflictError);
});
it('should store checkpoints and retrieve task state', async () => {
const { store } = await createStore();
const { taskId } = await store.createTask({
spec: {} as TaskSpec,
createdBy: 'me',
});
await store.saveTaskState({
taskId,
state: {
'repo.create': {
status: 'success',
value: { repoUrl: 'https://github.com/backstage/backstage.git' },
},
},
});
const state = await store.getTaskState({ taskId });
expect(state).toStrictEqual({
'repo.create': {
status: 'success',
value: { repoUrl: 'https://github.com/backstage/backstage.git' },
},
});
});
});
@@ -421,7 +421,7 @@ export class DatabaseTaskStore implements TaskStore {
: undefined;
}
async saveCheckpoint(options: {
async saveTaskState(options: {
taskId: string;
state?:
| {
@@ -124,7 +124,7 @@ export class TaskManager implements TaskContext {
} else {
this.task.state = { [key]: value };
}
await this.storage.saveCheckpoint?.({
await this.storage.saveTaskState?.({
taskId: this.task.taskId,
state: this.task.state,
});
@@ -206,7 +206,7 @@ export interface TaskStore {
| undefined
>;
saveCheckpoint?(options: {
saveTaskState?(options: {
taskId: string;
state?: {
[key: string]:
-1
View File
@@ -41307,7 +41307,6 @@ __metadata:
"@changesets/cli": ^2.14.0
"@manypkg/get-packages": ^1.1.3
"@octokit/rest": ^19.0.3
"@playwright/test": ^1.32.3
"@spotify/eslint-plugin": ^14.1.3
"@spotify/prettier-config": ^14.0.0
"@techdocs/cli": "workspace:*"