11import { escape } from 'querystring' ;
22import test from 'ava' ;
33import { stat } from 'fs-extra' ;
4+ import nock from 'nock' ;
45import { stub } from 'sinon' ;
56import clearModule from 'clear-module' ;
67import SemanticReleaseError from '@semantic-release/error' ;
@@ -31,6 +32,8 @@ test.beforeEach(t => {
3132test . afterEach . always ( ( ) => {
3233 // Restore process.env
3334 process . env = envBackup ;
35+ // Clear nock
36+ nock . cleanAll ( ) ;
3437} ) ;
3538
3639test . serial ( 'Verify Github auth' , async t => {
@@ -43,7 +46,7 @@ test.serial('Verify Github auth', async t => {
4346 . get ( `/repos/${ owner } /${ repo } ` )
4447 . reply ( 200 , { permissions : { push : true } } ) ;
4548
46- await t . notThrows ( t . context . m . verifyConditions ( { } , { options} ) ) ;
49+ await t . notThrows ( t . context . m . verifyConditions ( { } , { options, logger : t . context . logger } ) ) ;
4750
4851 t . true ( github . isDone ( ) ) ;
4952} ) ;
@@ -61,7 +64,7 @@ test.serial('Verify Github auth with publish options', async t => {
6164 . get ( `/repos/${ owner } /${ repo } ` )
6265 . reply ( 200 , { permissions : { push : true } } ) ;
6366
64- await t . notThrows ( t . context . m . verifyConditions ( { } , { options} ) ) ;
67+ await t . notThrows ( t . context . m . verifyConditions ( { } , { options, logger : t . context . logger } ) ) ;
6568
6669 t . true ( github . isDone ( ) ) ;
6770} ) ;
@@ -86,7 +89,7 @@ test.serial('Verify Github auth and assets config', async t => {
8689 . get ( `/repos/${ owner } /${ repo } ` )
8790 . reply ( 200 , { permissions : { push : true } } ) ;
8891
89- await t . notThrows ( t . context . m . verifyConditions ( { } , { options} ) ) ;
92+ await t . notThrows ( t . context . m . verifyConditions ( { } , { options, logger : t . context . logger } ) ) ;
9093
9194 t . true ( github . isDone ( ) ) ;
9295} ) ;
@@ -101,7 +104,7 @@ test.serial('Throw SemanticReleaseError if invalid config', async t => {
101104 repositoryUrl : `git+https://othertesturl.com/${ owner } /${ repo } .git` ,
102105 } ;
103106
104- const error = await t . throws ( t . context . m . verifyConditions ( { } , { options} ) ) ;
107+ const error = await t . throws ( t . context . m . verifyConditions ( { } , { options, logger : t . context . logger } ) ) ;
105108
106109 t . true ( error instanceof SemanticReleaseError ) ;
107110 t . is ( error . code , 'EINVALIDASSETS' ) ;
@@ -158,9 +161,10 @@ test.serial('Publish a release with an array of assets', async t => {
158161
159162 await t . context . m . publish ( { githubToken, assets} , { nextRelease, options, logger : t . context . logger } ) ;
160163
161- t . deepEqual ( t . context . log . args [ 0 ] , [ 'Published Github release: %s' , releaseUrl ] ) ;
162- t . deepEqual ( t . context . log . args [ 1 ] , [ 'Published file %s' , assetUrl ] ) ;
163- t . deepEqual ( t . context . log . args [ 2 ] , [ 'Published file %s' , otherAssetUrl ] ) ;
164+ t . deepEqual ( t . context . log . args [ 0 ] , [ 'Verify Github authentication' ] ) ;
165+ t . deepEqual ( t . context . log . args [ 1 ] , [ 'Published Github release: %s' , releaseUrl ] ) ;
166+ t . deepEqual ( t . context . log . args [ 2 ] , [ 'Published file %s' , assetUrl ] ) ;
167+ t . deepEqual ( t . context . log . args [ 3 ] , [ 'Published file %s' , otherAssetUrl ] ) ;
164168 t . true ( github . isDone ( ) ) ;
165169 t . true ( githubUpload1 . isDone ( ) ) ;
166170 t . true ( githubUpload2 . isDone ( ) ) ;
@@ -218,12 +222,13 @@ test.serial('Verify Github auth and release', async t => {
218222 . post ( `${ uploadUri } ?name=${ escape ( 'other_file.txt' ) } &label=${ escape ( 'Other File' ) } ` )
219223 . reply ( 200 , { browser_download_url : otherAssetUrl } ) ;
220224
221- await t . notThrows ( t . context . m . verifyConditions ( { } , { options} ) ) ;
225+ await t . notThrows ( t . context . m . verifyConditions ( { } , { options, logger : t . context . logger } ) ) ;
222226 await t . context . m . publish ( { assets} , { nextRelease, options, logger : t . context . logger } ) ;
223227
224- t . deepEqual ( t . context . log . args [ 0 ] , [ 'Published Github release: %s' , releaseUrl ] ) ;
225- t . deepEqual ( t . context . log . args [ 1 ] , [ 'Published file %s' , otherAssetUrl ] ) ;
226- t . deepEqual ( t . context . log . args [ 2 ] , [ 'Published file %s' , assetUrl ] ) ;
228+ t . deepEqual ( t . context . log . args [ 0 ] , [ 'Verify Github authentication' ] ) ;
229+ t . deepEqual ( t . context . log . args [ 1 ] , [ 'Published Github release: %s' , releaseUrl ] ) ;
230+ t . deepEqual ( t . context . log . args [ 2 ] , [ 'Published file %s' , otherAssetUrl ] ) ;
231+ t . deepEqual ( t . context . log . args [ 3 ] , [ 'Published file %s' , assetUrl ] ) ;
227232 t . true ( github . isDone ( ) ) ;
228233 t . true ( githubUpload1 . isDone ( ) ) ;
229234 t . true ( githubUpload2 . isDone ( ) ) ;
0 commit comments