4
4
import assert = require( 'assert' ) ;
5
5
import * as testutil from './testutil' ;
6
6
import * as tl from '../_build/task' ;
7
- import { IssueSource , _loadData } from '../_build/internal' ;
7
+ import { IssueAuditAction , IssueSource , _loadData } from '../_build/internal' ;
8
8
9
9
10
10
describe ( 'Task Issue command test without correlation ID' , function ( ) {
@@ -177,4 +177,77 @@ describe('Task Issue command test with correlation ID', function () {
177
177
178
178
done ( ) ;
179
179
} )
180
- } ) ;
180
+ } ) ;
181
+
182
+ describe ( 'Task Issue command, audit action tests' , function ( ) {
183
+ before ( function ( done ) {
184
+ try {
185
+ testutil . initialize ( ) ;
186
+ } catch ( err ) {
187
+ assert . fail ( 'Failed to load task lib: ' + err . message ) ;
188
+ }
189
+
190
+ done ( ) ;
191
+ } ) ;
192
+
193
+ after ( function ( done ) {
194
+ done ( ) ;
195
+ } ) ;
196
+
197
+ it ( 'Audit action is present in issue' , function ( done ) {
198
+ this . timeout ( 1000 ) ;
199
+
200
+ const stdStream = testutil . createStringStream ( ) ;
201
+ tl . setStdStream ( stdStream ) ;
202
+
203
+ const expected = testutil . buildOutput (
204
+ [ '##vso[task.issue type=error;auditAction=1;]Test error' ,
205
+ '##vso[task.issue type=warning;auditAction=1;]Test warning' ] ) ;
206
+
207
+ tl . error ( "Test error" , null , IssueAuditAction . ShellTasksValidation ) ;
208
+ tl . warning ( "Test warning" , null , IssueAuditAction . ShellTasksValidation ) ;
209
+
210
+ const output = stdStream . getContents ( ) ;
211
+
212
+ assert . strictEqual ( output , expected ) ;
213
+ done ( ) ;
214
+ } )
215
+
216
+ it ( 'Audit action not present if unspecified' , function ( done ) {
217
+ this . timeout ( 1000 ) ;
218
+
219
+ const stdStream = testutil . createStringStream ( ) ;
220
+ tl . setStdStream ( stdStream ) ;
221
+
222
+ const expected = testutil . buildOutput (
223
+ [ '##vso[task.issue type=error;]Test error' ,
224
+ '##vso[task.issue type=warning;]Test warning' ] ) ;
225
+
226
+ tl . error ( "Test error" , null ) ;
227
+ tl . warning ( "Test warning" , null ) ;
228
+
229
+ const output = stdStream . getContents ( ) ;
230
+
231
+ assert . strictEqual ( output , expected ) ;
232
+ done ( ) ;
233
+ } )
234
+
235
+ it ( 'Audit action is present when value is not from enum' , function ( done ) {
236
+ this . timeout ( 1000 ) ;
237
+
238
+ const stdStream = testutil . createStringStream ( ) ;
239
+ tl . setStdStream ( stdStream ) ;
240
+
241
+ const expected = testutil . buildOutput (
242
+ [ '##vso[task.issue type=error;auditAction=123;]Test error' ,
243
+ '##vso[task.issue type=warning;auditAction=321;]Test warning' ] ) ;
244
+
245
+ tl . error ( "Test error" , null , 123 as IssueAuditAction ) ;
246
+ tl . warning ( "Test warning" , null , 321 as IssueAuditAction ) ;
247
+
248
+ const output = stdStream . getContents ( ) ;
249
+
250
+ assert . strictEqual ( output , expected ) ;
251
+ done ( ) ;
252
+ } )
253
+ } ) ;
0 commit comments