-
Notifications
You must be signed in to change notification settings - Fork 4
/
testRun.ts
75 lines (66 loc) · 1.87 KB
/
testRun.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import { ITestApi } from 'azure-devops-node-api/TestApi'
import { IAzureConfig } from '../../interfaces/IAzureConfig'
import { RunCreateModel } from '../../model/runCreateModel'
import { getPoints } from './testCasePoints'
import * as TestInterfaces from 'azure-devops-node-api/interfaces/TestInterfaces'
import { AxiosInstance } from 'axios'
export async function createTestRun(
azureClient: ITestApi,
axiosClient: AxiosInstance,
azureConfig: IAzureConfig
): Promise<TestInterfaces.TestRun> {
const plan = {
id: `${azureConfig.planId}`,
name: azureConfig.runName,
}
const pointIds = await getPoints(axiosClient, azureConfig)
const testRunModel = new RunCreateModel(azureConfig.runName, plan, pointIds)
return azureClient.createTestRun(testRunModel, azureConfig.projectId)
}
export async function setInProgressRun(
azureClient: ITestApi,
azureConfig: IAzureConfig,
testRunId: number
): Promise<TestInterfaces.TestRun> {
const inProgressRunModel: TestInterfaces.RunUpdateModel = {
state: 'InProgress',
}
return azureClient.updateTestRun(
inProgressRunModel,
azureConfig.projectId,
testRunId
)
}
export async function setCompletedRun(
azureClient: ITestApi,
azureConfig: IAzureConfig,
testRunId: number
): Promise<TestInterfaces.TestRun> {
const inProgressRunModel: TestInterfaces.RunUpdateModel = {
state: 'Completed',
}
return azureClient.updateTestRun(
inProgressRunModel,
azureConfig.projectId,
testRunId
)
}
export async function getLastTestRunId(
azureClient: ITestApi,
azureConfig: IAzureConfig
): Promise<number> {
const testRun = await azureClient.getTestRuns(
azureConfig.projectId,
undefined,
undefined,
undefined,
azureConfig.planId,
undefined,
undefined,
undefined
)
if (!testRun || !testRun.length) {
throw new Error()
}
return testRun[testRun.length - 1].id
}