Skip to content

Commit

Permalink
feat: add cancel method
Browse files Browse the repository at this point in the history
  • Loading branch information
mdonnalley committed Nov 20, 2024
1 parent 615c65e commit 8371f9f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/agentTester.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,12 @@ export class AgentTester {
: await jsonFormat(response),
};
}

public async cancel(jobId: string): Promise<{ success: boolean }> {
const url = `/einstein/ai-evaluations/runs/${jobId}/cancel`;

return this.maybeMock.request<{ success: boolean }>('POST', url);
}
}

export async function humanFormat(details: AgentTestDetailsResponse): Promise<string> {
Expand Down Expand Up @@ -188,7 +194,7 @@ export async function junitFormat(details: AgentTestDetailsResponse): Promise<st
}

export async function tapFormat(details: AgentTestDetailsResponse): Promise<string> {
// APEX EXAMPLE
// APEX EXAMPLE (these are streamed in chunks)
// 1..11
// ok 1 TestPropertyController.testGetPagedPropertyList
// ok 2 TestPropertyController.testGetPicturesNoResults
Expand Down
2 changes: 1 addition & 1 deletion src/maybe-mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export class MaybeMock {
public async request<T extends nock.Body>(
method: 'GET' | 'POST',
url: string,
body?: nock.RequestBodyMatcher
body: nock.RequestBodyMatcher = {}
): Promise<T> {
if (this.mockDir) {
this.logger.debug(`Mocking ${method} request to ${url} using ${this.mockDir}`);
Expand Down
9 changes: 9 additions & 0 deletions test/agentTester.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,13 @@ describe('AgentTester', () => {
expect(output).to.be.ok;
});
});

describe('cancel', () => {
it('should cancel test run', async () => {
const tester = new AgentTester(connection);
await tester.start('suiteId');
const output = await tester.cancel('4KBSM000000003F4AQ');
expect(output.success).to.be.true;
});
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"success": true
}

0 comments on commit 8371f9f

Please sign in to comment.