diff options
Diffstat (limited to 'shared/extra-utils/server/jobs.ts')
-rw-r--r-- | shared/extra-utils/server/jobs.ts | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/shared/extra-utils/server/jobs.ts b/shared/extra-utils/server/jobs.ts index cac00e9ab..a53749589 100644 --- a/shared/extra-utils/server/jobs.ts +++ b/shared/extra-utils/server/jobs.ts | |||
@@ -1,12 +1,20 @@ | |||
1 | import * as request from 'supertest' | 1 | import * as request from 'supertest' |
2 | import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' | ||
3 | import { makeGetRequest } from '../../../shared/extra-utils' | ||
2 | import { Job, JobState, JobType } from '../../models' | 4 | import { Job, JobState, JobType } from '../../models' |
3 | import { wait } from '../miscs/miscs' | 5 | import { wait } from '../miscs/miscs' |
4 | import { ServerInfo } from './servers' | 6 | import { ServerInfo } from './servers' |
5 | import { makeGetRequest } from '../../../shared/extra-utils' | ||
6 | import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' | ||
7 | 7 | ||
8 | function getJobsList (url: string, accessToken: string, state: JobState) { | 8 | function buildJobsUrl (state?: JobState) { |
9 | const path = '/api/v1/jobs/' + state | 9 | let path = '/api/v1/jobs' |
10 | |||
11 | if (state) path += '/' + state | ||
12 | |||
13 | return path | ||
14 | } | ||
15 | |||
16 | function getJobsList (url: string, accessToken: string, state?: JobState) { | ||
17 | const path = buildJobsUrl(state) | ||
10 | 18 | ||
11 | return request(url) | 19 | return request(url) |
12 | .get(path) | 20 | .get(path) |
@@ -19,14 +27,14 @@ function getJobsList (url: string, accessToken: string, state: JobState) { | |||
19 | function getJobsListPaginationAndSort (options: { | 27 | function getJobsListPaginationAndSort (options: { |
20 | url: string | 28 | url: string |
21 | accessToken: string | 29 | accessToken: string |
22 | state: JobState | ||
23 | start: number | 30 | start: number |
24 | count: number | 31 | count: number |
25 | sort: string | 32 | sort: string |
33 | state?: JobState | ||
26 | jobType?: JobType | 34 | jobType?: JobType |
27 | }) { | 35 | }) { |
28 | const { url, accessToken, state, start, count, sort, jobType } = options | 36 | const { url, accessToken, state, start, count, sort, jobType } = options |
29 | const path = '/api/v1/jobs/' + state | 37 | const path = buildJobsUrl(state) |
30 | 38 | ||
31 | const query = { | 39 | const query = { |
32 | start, | 40 | start, |