1
1
import * as assert from 'assert' ;
2
2
import * as utils from '../utils.js' ;
3
3
import * as ttm from 'azure-pipelines-task-lib/mock-test' ;
4
+ import { Done } from 'mocha' ;
4
5
import fs = require( 'fs' ) ;
5
6
import os = require( 'os' ) ;
6
7
import path = require( 'path' ) ;
7
8
import tl = require( 'azure-pipelines-task-lib/task' ) ;
8
9
9
10
describe ( 'ArchiveFiles L0 Suite' , function ( ) {
10
- function runValidations ( validator : ( ) => void , tr , done ) {
11
+ function runValidations ( validator : ( ) => void , tr : ttm . MockTestRunner , done : Done ) {
11
12
try {
12
13
validator ( ) ;
13
14
done ( ) ;
@@ -18,7 +19,7 @@ describe('ArchiveFiles L0 Suite', function () {
18
19
done ( error ) ;
19
20
}
20
21
}
21
-
22
+
22
23
before ( ( ) => {
23
24
const testTemp = path . join ( __dirname , 'test_temp' ) ;
24
25
if ( ! fs . existsSync ( testTemp ) ) {
@@ -30,28 +31,28 @@ describe('ArchiveFiles L0 Suite', function () {
30
31
}
31
32
} )
32
33
33
- const files = ( n ) => {
34
+ const files = ( n : number ) => {
34
35
return Array . from (
35
36
{ length : n } , ( v , k ) => String ( k )
36
37
)
37
38
} ;
38
39
39
40
let test = this ;
40
41
let cases = [ 0 , 1 , 10 , 11 , 100 ] ;
41
-
42
+
42
43
tl . setResourcePath ( path . join ( __dirname , '..' , 'task.json' ) ) ;
43
44
cases . forEach ( function ( numberOfFiles ) {
44
45
it ( 'Verify plan output for ' + numberOfFiles + ' files has correct number of lines' , ( done : MochaDone ) => {
45
46
test . timeout ( 1000 ) ;
46
47
let max = 10 ;
47
48
let plan = utils . reportArchivePlan ( files ( numberOfFiles ) , max ) ;
48
49
assert ( plan . length == Math . min ( numberOfFiles + 1 , max + 2 ) ) ;
49
-
50
+
50
51
done ( ) ;
51
52
} ) ;
52
53
} ) ;
53
54
54
- it ( 'Successfully creates a zip' , function ( done : MochaDone ) {
55
+ it ( 'Successfully creates a zip' , function ( done : Done ) {
55
56
this . timeout ( 10000 ) ;
56
57
process . env [ 'archiveType' ] = 'zip' ;
57
58
process . env [ 'archiveFile' ] = 'myZip' ;
@@ -79,7 +80,7 @@ describe('ArchiveFiles L0 Suite', function () {
79
80
} , tr , done ) ;
80
81
} ) ;
81
82
82
- it ( 'Successfully creates a tar' , function ( done : MochaDone ) {
83
+ it ( 'Successfully creates a tar' , function ( done : Done ) {
83
84
this . timeout ( 5000 ) ;
84
85
process . env [ 'archiveType' ] = 'tar' ;
85
86
process . env [ 'archiveFile' ] = 'myTar' ;
@@ -102,7 +103,7 @@ describe('ArchiveFiles L0 Suite', function () {
102
103
103
104
// These tests rely on 7z which isnt present on macOS
104
105
if ( process . platform . indexOf ( 'darwin' ) < 0 ) {
105
- it ( 'Successfully creates a 7z' , function ( done : MochaDone ) {
106
+ it ( 'Successfully creates a 7z' , function ( done : Done ) {
106
107
this . timeout ( 5000 ) ;
107
108
process . env [ 'archiveType' ] = '7z' ;
108
109
process . env [ 'archiveFile' ] = 'my7z' ;
@@ -120,7 +121,7 @@ if (process.platform.indexOf('darwin') < 0) {
120
121
} , tr , done ) ;
121
122
} ) ;
122
123
123
- it ( 'Successfully creates a wim' , function ( done : MochaDone ) {
124
+ it ( 'Successfully creates a wim' , function ( done : Done ) {
124
125
this . timeout ( 5000 ) ;
125
126
process . env [ 'archiveType' ] = 'wim' ;
126
127
process . env [ 'archiveFile' ] = 'mywim' ;
0 commit comments