1
- import { rmRF } from '@actions/io' ;
2
- import * as path from 'path' ;
3
-
4
1
import * as util from '../util' ;
2
+ import { prepareTestFolders } from '../util/io' ;
5
3
6
4
const KNOWN_HOSTS_WARNING = `
7
5
##[warning] KNOWN_HOSTS_FILE not set
@@ -22,20 +20,16 @@ that the public key has been added to the target repo
22
20
23
21
describe ( 'Misconfigurations' , ( ) => {
24
22
xit ( 'missing-known-hosts' , async ( ) => {
25
- const testname = `misconfiguration-missing-known-hosts` ;
26
- const dataDir = path . join ( util . DATA_DIR , testname ) ;
27
-
28
- await rmRF ( dataDir ) ;
29
- await util . mkdir ( dataDir ) ;
23
+ const folders = await prepareTestFolders ( { __filename } ) ;
30
24
31
25
// Run Action
32
26
await util
33
27
. runWithGithubEnv (
34
- testname ,
28
+ folders . testName ,
35
29
{
36
- REPO : 'ssh://git@git-ssh/git-server/repos/non-existing.git' ,
30
+ REPO : folders . repoUrl ,
37
31
BRANCH : 'branch-a' ,
38
- FOLDER : dataDir ,
32
+ FOLDER : folders . dataDir ,
39
33
SSH_PRIVATE_KEY : (
40
34
await util . readFile ( util . SSH_PRIVATE_KEY )
41
35
) . toString ( ) ,
@@ -63,16 +57,15 @@ describe('Misconfigurations', () => {
63
57
} ) ;
64
58
65
59
it ( 'missing-repo' , async ( ) => {
66
- const testname = `misconfiguration-missing-repo` ;
67
- const dataDir = path . join ( util . DATA_DIR , testname ) ;
60
+ const folders = await prepareTestFolders ( { __filename } ) ;
68
61
69
62
// Run Action
70
63
await util
71
64
. runWithGithubEnv (
72
- testname ,
65
+ folders . testName ,
73
66
{
74
67
BRANCH : 'branch-a' ,
75
- FOLDER : dataDir ,
68
+ FOLDER : folders . dataDir ,
76
69
} ,
77
70
's0/test' ,
78
71
{ } ,
@@ -98,14 +91,14 @@ describe('Misconfigurations', () => {
98
91
} ) ;
99
92
100
93
it ( 'missing-folder' , async ( ) => {
101
- const testname = `misconfiguration-missing-folder` ;
94
+ const folders = await prepareTestFolders ( { __filename } ) ;
102
95
103
96
// Run Action
104
97
await util
105
98
. runWithGithubEnv (
106
- testname ,
99
+ folders . testName ,
107
100
{
108
- REPO : 'ssh://git@git-ssh/git-server/repos/non-existing.git' ,
101
+ REPO : folders . repoUrl ,
109
102
BRANCH : 'branch-a' ,
110
103
} ,
111
104
's0/test' ,
@@ -132,16 +125,15 @@ describe('Misconfigurations', () => {
132
125
} ) ;
133
126
134
127
it ( 'missing-branch' , async ( ) => {
135
- const testname = `misconfiguration-missing-branch` ;
136
- const dataDir = path . join ( util . DATA_DIR , testname ) ;
128
+ const folders = await prepareTestFolders ( { __filename } ) ;
137
129
138
130
// Run Action
139
131
await util
140
132
. runWithGithubEnv (
141
- testname ,
133
+ folders . testName ,
142
134
{
143
- REPO : 'ssh://git@git-ssh/git-server/repos/non-existing.git' ,
144
- FOLDER : dataDir ,
135
+ REPO : folders . repoUrl ,
136
+ FOLDER : folders . dataDir ,
145
137
} ,
146
138
's0/test' ,
147
139
{ } ,
@@ -167,17 +159,16 @@ describe('Misconfigurations', () => {
167
159
} ) ;
168
160
169
161
it ( 'missing-event-path' , async ( ) => {
170
- const testname = `misconfiguration-missing-event-path` ;
171
- const dataDir = path . join ( util . DATA_DIR , testname ) ;
162
+ const folders = await prepareTestFolders ( { __filename } ) ;
172
163
173
164
// Run Action
174
165
await util
175
166
. runWithGithubEnv (
176
- testname ,
167
+ folders . testName ,
177
168
{
178
- REPO : 'ssh://git@git-ssh/git-server/repos/non-existing.git' ,
169
+ REPO : folders . repoUrl ,
179
170
BRANCH : 'branch-a' ,
180
- FOLDER : dataDir ,
171
+ FOLDER : folders . dataDir ,
181
172
SSH_PRIVATE_KEY : (
182
173
await util . readFile ( util . SSH_PRIVATE_KEY )
183
174
) . toString ( ) ,
@@ -207,17 +198,16 @@ describe('Misconfigurations', () => {
207
198
} ) ;
208
199
209
200
it ( 'missing-ssh-private-key' , async ( ) => {
210
- const testname = `misconfiguration-missing-ssh-private-key` ;
211
- const dataDir = path . join ( util . DATA_DIR , testname ) ;
201
+ const folders = await prepareTestFolders ( { __filename } ) ;
212
202
213
203
// Run Action
214
204
await util
215
205
. runWithGithubEnv (
216
- testname ,
206
+ folders . testName ,
217
207
{
218
- REPO : 'ssh://git@git-ssh/git-server/repos/non-existing.git' ,
208
+ REPO : folders . repoUrl ,
219
209
BRANCH : 'branch-a' ,
220
- FOLDER : dataDir ,
210
+ FOLDER : folders . dataDir ,
221
211
} ,
222
212
's0/test' ,
223
213
{ } ,
@@ -245,17 +235,16 @@ describe('Misconfigurations', () => {
245
235
} ) ;
246
236
247
237
it ( 'unsupported-http-repo' , async ( ) => {
248
- const testname = `misconfiguration-unsupported-http-repo` ;
249
- const dataDir = path . join ( util . DATA_DIR , testname ) ;
238
+ const folders = await prepareTestFolders ( { __filename } ) ;
250
239
251
240
// Run Action
252
241
await util
253
242
. runWithGithubEnv (
254
- testname ,
243
+ folders . testName ,
255
244
{
256
245
REPO : 'https://github.com/s0/git-publish-subdir-action-tests.git' ,
257
246
BRANCH : 'branch-a' ,
258
- FOLDER : dataDir ,
247
+ FOLDER : folders . dataDir ,
259
248
} ,
260
249
's0/test' ,
261
250
{ } ,
@@ -280,20 +269,16 @@ describe('Misconfigurations', () => {
280
269
} ) ;
281
270
} ) ;
282
271
it ( 'unauthorized-ssh-key' , async ( ) => {
283
- const testname = `unauthorized-ssh-key` ;
284
- const dataDir = path . join ( util . DATA_DIR , testname ) ;
285
-
286
- await rmRF ( dataDir ) ;
287
- await util . mkdir ( dataDir ) ;
272
+ const folders = await prepareTestFolders ( { __filename } ) ;
288
273
289
274
// Run Action
290
275
await util
291
276
. runWithGithubEnv (
292
- testname ,
277
+ folders . testName ,
293
278
{
294
- REPO : 'ssh://git@git-ssh/git-server/repos/ssh-no-branch.git' ,
279
+ REPO : folders . repoUrl ,
295
280
BRANCH : 'branch-a' ,
296
- FOLDER : dataDir ,
281
+ FOLDER : folders . dataDir ,
297
282
SSH_PRIVATE_KEY : (
298
283
await util . readFile ( util . SSH_PRIVATE_KEY_INVALID )
299
284
) . toString ( ) ,
@@ -320,20 +305,16 @@ describe('Misconfigurations', () => {
320
305
} ) ;
321
306
} ) ;
322
307
it ( 'self-missing-token' , async ( ) => {
323
- const testname = `uself-missing-token` ;
324
- const dataDir = path . join ( util . DATA_DIR , testname ) ;
325
-
326
- await rmRF ( dataDir ) ;
327
- await util . mkdir ( dataDir ) ;
308
+ const folders = await prepareTestFolders ( { __filename } ) ;
328
309
329
310
// Run Action
330
311
await util
331
312
. runWithGithubEnv (
332
- testname ,
313
+ folders . testName ,
333
314
{
334
315
REPO : 'self' ,
335
316
BRANCH : 'tmp-test-branch' ,
336
- FOLDER : dataDir ,
317
+ FOLDER : folders . dataDir ,
337
318
} ,
338
319
's0/test' ,
339
320
{ } ,
@@ -361,20 +342,16 @@ describe('Misconfigurations', () => {
361
342
} ) ;
362
343
363
344
it ( 'self-missing-repo' , async ( ) => {
364
- const testname = `uself-missing-repo` ;
365
- const dataDir = path . join ( util . DATA_DIR , testname ) ;
366
-
367
- await rmRF ( dataDir ) ;
368
- await util . mkdir ( dataDir ) ;
345
+ const folders = await prepareTestFolders ( { __filename } ) ;
369
346
370
347
// Run Action
371
348
await util
372
349
. runWithGithubEnv (
373
- testname ,
350
+ folders . testName ,
374
351
{
375
352
REPO : 'self' ,
376
353
BRANCH : 'tmp-test-branch' ,
377
- FOLDER : dataDir ,
354
+ FOLDER : folders . dataDir ,
378
355
GITHUB_TOKEN : 'foobar' ,
379
356
} ,
380
357
undefined ,
0 commit comments