-
Notifications
You must be signed in to change notification settings - Fork 226
Expand file tree
/
Copy pathrun-remote-query.test.ts
More file actions
238 lines (222 loc) · 9.26 KB
/
run-remote-query.test.ts
File metadata and controls
238 lines (222 loc) · 9.26 KB
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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
import { expect } from 'chai';
import * as os from 'os';
import { parseResponse } from '../../../remote-queries/run-remote-query';
describe('run-remote-query', () => {
describe('parseResponse', () => {
it('should parse a successful response', () => {
const result = parseResponse('org', 'name', {
workflow_run_id: 123,
repositories_queried: ['a/b', 'c/d'],
});
expect(result.popupMessage).to.equal('Successfully scheduled runs on 2 repositories. [Click here to see the progress](https://github.com/org/name/actions/runs/123).');
expect(result.logMessage).to.equal(
['Successfully scheduled runs on 2 repositories. See https://github.com/org/name/actions/runs/123.',
'',
'Repositories queried:',
'a/b, c/d'].join(os.EOL),
);
});
it('should parse a response with invalid repos', () => {
const result = parseResponse('org', 'name', {
workflow_run_id: 123,
repositories_queried: ['a/b', 'c/d'],
errors: {
invalid_repositories: ['e/f', 'g/h'],
}
});
expect(result.popupMessage).to.equal(
['Successfully scheduled runs on 2 repositories. [Click here to see the progress](https://github.com/org/name/actions/runs/123).',
'',
'Some repositories could not be scheduled. See extension log for details.'].join(os.EOL)
);
expect(result.logMessage).to.equal(
['Successfully scheduled runs on 2 repositories. See https://github.com/org/name/actions/runs/123.',
'',
'Repositories queried:',
'a/b, c/d',
'',
'Some repositories could not be scheduled.',
'',
'2 repositories invalid and could not be found:',
'e/f, g/h'].join(os.EOL)
);
});
it('should parse a response with repos w/o databases', () => {
const result = parseResponse('org', 'name', {
workflow_run_id: 123,
repositories_queried: ['a/b', 'c/d'],
errors: {
repositories_without_database: ['e/f', 'g/h'],
}
});
expect(result.popupMessage).to.equal(
['Successfully scheduled runs on 2 repositories. [Click here to see the progress](https://github.com/org/name/actions/runs/123).',
'',
'Some repositories could not be scheduled. See extension log for details.'].join(os.EOL)
);
expect(result.logMessage).to.equal(
['Successfully scheduled runs on 2 repositories. See https://github.com/org/name/actions/runs/123.',
'',
'Repositories queried:',
'a/b, c/d',
'',
'Some repositories could not be scheduled.',
'',
'2 repositories did not have a CodeQL database available:',
'e/f, g/h',
'For each public repository that has not yet been added to the database service, we will try to create a database next time the store is updated.'].join(os.EOL)
);
});
it('should parse a response with private repos', () => {
const result = parseResponse('org', 'name', {
workflow_run_id: 123,
repositories_queried: ['a/b', 'c/d'],
errors: {
private_repositories: ['e/f', 'g/h'],
}
});
expect(result.popupMessage).to.equal(
['Successfully scheduled runs on 2 repositories. [Click here to see the progress](https://github.com/org/name/actions/runs/123).',
'',
'Some repositories could not be scheduled. See extension log for details.'].join(os.EOL)
);
expect(result.logMessage).to.equal(
['Successfully scheduled runs on 2 repositories. See https://github.com/org/name/actions/runs/123.',
'',
'Repositories queried:',
'a/b, c/d',
'',
'Some repositories could not be scheduled.',
'',
'2 repositories not public:',
'e/f, g/h',
'When using a public controller repository, only public repositories can be queried.'].join(os.EOL)
);
});
it('should parse a response with cutoff repos and cutoff repos count', () => {
const result = parseResponse('org', 'name', {
workflow_run_id: 123,
repositories_queried: ['a/b', 'c/d'],
errors: {
cutoff_repositories: ['e/f', 'g/h'],
cutoff_repositories_count: 2,
}
});
expect(result.popupMessage).to.equal(
['Successfully scheduled runs on 2 repositories. [Click here to see the progress](https://github.com/org/name/actions/runs/123).',
'',
'Some repositories could not be scheduled. See extension log for details.'].join(os.EOL)
);
expect(result.logMessage).to.equal(
['Successfully scheduled runs on 2 repositories. See https://github.com/org/name/actions/runs/123.',
'',
'Repositories queried:',
'a/b, c/d',
'',
'Some repositories could not be scheduled.',
'',
'2 repositories over the limit for a single request:',
'e/f, g/h',
'Repositories were selected based on how recently they had been updated.'].join(os.EOL)
);
});
it('should parse a response with cutoff repos count but not cutoff repos', () => {
const result = parseResponse('org', 'name', {
workflow_run_id: 123,
repositories_queried: ['a/b', 'c/d'],
errors: {
cutoff_repositories_count: 2,
}
});
expect(result.popupMessage).to.equal(
['Successfully scheduled runs on 2 repositories. [Click here to see the progress](https://github.com/org/name/actions/runs/123).',
'',
'Some repositories could not be scheduled. See extension log for details.'].join(os.EOL)
);
expect(result.logMessage).to.equal(
['Successfully scheduled runs on 2 repositories. See https://github.com/org/name/actions/runs/123.',
'',
'Repositories queried:',
'a/b, c/d',
'',
'Some repositories could not be scheduled.',
'',
'2 repositories over the limit for a single request.',
'Repositories were selected based on how recently they had been updated.'].join(os.EOL)
);
});
it('should parse a response with invalid repos and repos w/o databases', () => {
const result = parseResponse('org', 'name', {
workflow_run_id: 123,
repositories_queried: ['a/b', 'c/d'],
errors: {
invalid_repositories: ['e/f', 'g/h'],
repositories_without_database: ['i/j', 'k/l'],
}
});
expect(result.popupMessage).to.equal(
['Successfully scheduled runs on 2 repositories. [Click here to see the progress](https://github.com/org/name/actions/runs/123).',
'',
'Some repositories could not be scheduled. See extension log for details.'].join(os.EOL)
);
expect(result.logMessage).to.equal(
['Successfully scheduled runs on 2 repositories. See https://github.com/org/name/actions/runs/123.',
'',
'Repositories queried:',
'a/b, c/d',
'',
'Some repositories could not be scheduled.',
'',
'2 repositories invalid and could not be found:',
'e/f, g/h',
'',
'2 repositories did not have a CodeQL database available:',
'i/j, k/l',
'For each public repository that has not yet been added to the database service, we will try to create a database next time the store is updated.'].join(os.EOL)
);
});
it('should parse a response with one repo of each category, and not pluralize "repositories"', () => {
const result = parseResponse('org', 'name', {
workflow_run_id: 123,
repositories_queried: ['a/b'],
errors: {
private_repositories: ['e/f'],
cutoff_repositories: ['i/j'],
cutoff_repositories_count: 1,
invalid_repositories: ['m/n'],
repositories_without_database: ['q/r'],
}
});
expect(result.popupMessage).to.equal(
['Successfully scheduled runs on 1 repository. [Click here to see the progress](https://github.com/org/name/actions/runs/123).',
'',
'Some repositories could not be scheduled. See extension log for details.'].join(os.EOL)
);
expect(result.logMessage).to.equal(
[
'Successfully scheduled runs on 1 repository. See https://github.com/org/name/actions/runs/123.',
'',
'Repositories queried:',
'a/b',
'',
'Some repositories could not be scheduled.',
'',
'1 repository invalid and could not be found:',
'm/n',
'',
'1 repository did not have a CodeQL database available:',
'q/r',
'For each public repository that has not yet been added to the database service, we will try to create a database next time the store is updated.',
'',
'1 repository not public:',
'e/f',
'When using a public controller repository, only public repositories can be queried.',
'',
'1 repository over the limit for a single request:',
'i/j',
'Repositories were selected based on how recently they had been updated.',
].join(os.EOL)
);
});
});
});