Skip to content

Commit 08f7913

Browse files
authored
Fix TestRails listSuites method to properly paginate results (#2192)
1 parent fca8a4e commit 08f7913

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

sources/testrails-source/src/testrails/testrails-client.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
PagedResponse,
1212
PagedResults,
1313
PagedRuns,
14+
PagedSuites,
1415
PagedTests,
1516
TestRailsCase,
1617
TestRailsCaseType,
@@ -96,8 +97,16 @@ export class TestRailsClient {
9697
* @param projectId The project to retrieve suites for
9798
* @returns The TestRails suites
9899
*/
100+
@Memoize()
99101
async listSuites(projectId: string): Promise<TestRailsSuite[]> {
100-
return this.get(`/get_suites/${projectId}`);
102+
const suites = [];
103+
for await (const suite of this.paginate(
104+
`/get_suites/${projectId}`,
105+
(res: PagedSuites) => res.suites
106+
)) {
107+
suites.push(suite);
108+
}
109+
return suites;
101110
}
102111

103112
/**

sources/testrails-source/src/testrails/testrails-models.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ export interface TestRailsSuite {
3838
readonly completed_on: number;
3939
}
4040

41+
export interface PagedSuites extends PagedResponse {
42+
readonly suites: TestRailsSuite[];
43+
}
44+
4145
export interface TestRailsCase {
4246
readonly id: number;
4347
readonly title: string;

0 commit comments

Comments
 (0)