-
Notifications
You must be signed in to change notification settings - Fork 16
/
ext-ci-info.spec.js
185 lines (176 loc) · 5.19 KB
/
ext-ci-info.spec.js
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
const { mock } = require('pactum');
const assert = require('assert');
const { publish } = require('../src');
describe('extensions - ci-info', () => {
beforeEach(() => {
process.env.GITHUB_ACTIONS = '';
process.env.GITHUB_SERVER_URL = '';
process.env.GITHUB_REPOSITORY = '';
process.env.GITHUB_REF = '';
process.env.GITHUB_SHA = '';
process.env.GITHUB_RUN_ID = '';
process.env.GITHUB_RUN_NUMBER = '';
process.env.GITHUB_WORKFLOW = '';
process.env.SYSTEM_TEAMFOUNDATIONCOLLECTIONURI = '';
process.env.BUILD_REPOSITORY_URI = '';
process.env.BUILD_REPOSITORY_NAME = '';
process.env.BUILD_SOURCEBRANCH = '';
process.env.BUILD_SOURCEVERSION = '';
process.env.BUILD_BUILDID = '';
process.env.BUILD_BUILDNUMBER = '';
process.env.BUILD_DEFINITIONNAME = '';
});
it('should send test-summary with ci-info to teams with no ci information', async () => {
const id = mock.addInteraction('post test-summary to teams');
await publish({
config: {
targets: [
{
name: 'teams',
inputs: {
url: 'http://localhost:9393/message'
},
extensions: [
{
name: 'ci-info'
}
]
}
],
results: [
{
type: 'testng',
files: [
'test/data/testng/single-suite.xml'
]
}
]
}
});
assert.equal(mock.getInteraction(id).exercised, true);
});
it('should send test-summary with github ci information to teams', async () => {
process.env.GITHUB_ACTIONS = 'GITHUB_ACTIONS';
process.env.GITHUB_SERVER_URL = 'https://github.com';
process.env.GITHUB_REPOSITORY = 'test/test';
process.env.GITHUB_REF = '/refs/heads/feature-test';
process.env.GITHUB_SHA = 'sha';
process.env.GITHUB_RUN_ID = 'id-123';
process.env.GITHUB_RUN_NUMBER = 'number-123';
process.env.GITHUB_WORKFLOW = 'Build';
const id = mock.addInteraction('post test-summary with ci-info to teams');
await publish({
config: {
targets: [
{
name: 'teams',
inputs: {
url: 'http://localhost:9393/message'
},
extensions: [
{
name: 'ci-info'
}
]
}
],
results: [
{
type: 'testng',
files: [
'test/data/testng/single-suite.xml'
]
}
]
}
});
assert.equal(mock.getInteraction(id).exercised, true);
});
it('should send test-summary with azure devops ci information to slack', async () => {
process.env.SYSTEM_TEAMFOUNDATIONCOLLECTIONURI = 'https://dev.azure.com/';
process.env.SYSTEM_TEAMPROJECT = 'test';
process.env.BUILD_REPOSITORY_URI = 'https://github.com/test/test';
process.env.BUILD_REPOSITORY_NAME = 'test/test';
process.env.BUILD_SOURCEBRANCH = '/refs/pull/123/merge';
process.env.BUILD_SOURCEVERSION = 'sha';
process.env.BUILD_BUILDID = 'id-123';
process.env.BUILD_BUILDNUMBER = 'number-123';
process.env.BUILD_DEFINITIONNAME = 'Build';
const id = mock.addInteraction('post test-summary with ci-info to slack');
await publish({
config: {
targets: [
{
name: 'slack',
inputs: {
url: 'http://localhost:9393/message'
},
extensions: [
{
name: 'ci-info'
}
]
}
],
results: [
{
type: 'testng',
files: [
'test/data/testng/single-suite.xml'
]
}
]
}
});
assert.equal(mock.getInteraction(id).exercised, true);
});
it('should send test-summary with azure devops ci information to chat and extra data', async () => {
process.env.GITHUB_ACTIONS = 'GITHUB_ACTIONS';
process.env.GITHUB_SERVER_URL = 'https://github.com';
process.env.GITHUB_REPOSITORY = 'org/repo';
process.env.GITHUB_REF = '/refs/heads/feature-test';
process.env.GITHUB_SHA = 'sha';
process.env.GITHUB_RUN_ID = 'id-123';
process.env.GITHUB_RUN_NUMBER = 'number-123';
process.env.GITHUB_WORKFLOW = 'Build';
const id = mock.addInteraction('post test-summary with ci-info to chat');
await publish({
config: {
targets: [
{
name: 'chat',
inputs: {
url: 'http://localhost:9393/message'
},
extensions: [
{
name: 'ci-info',
inputs: {
data: [
{
"key": "Download Logs",
"value": "{LOGS_URL}",
"type": "hyperlink"
}
]
}
}
]
}
],
results: [
{
type: 'testng',
files: [
'test/data/testng/single-suite.xml'
]
}
]
}
});
assert.equal(mock.getInteraction(id).exercised, true);
});
afterEach(() => {
mock.clearInteractions();
});
});