1- import { promisify } from 'util' ;
21import { escape } from 'querystring' ;
32import test from 'ava' ;
43import { stub , match } from 'sinon' ;
@@ -36,14 +35,13 @@ test.serial('Verify Github auth', async t => {
3635 process . env . GITHUB_TOKEN = 'github_token' ;
3736 const owner = 'test_user' ;
3837 const repo = 'test_repo' ;
39- const options = { } ;
40- const pkg = { name : 'package-name' , repository : { url : `git+https://othertesturl.com/${ owner } /${ repo } .git` } } ;
38+ const options = { repositoryUrl : `git+https://othertesturl.com/${ owner } /${ repo } .git` } ;
4139
4240 const github = authenticate ( { githubToken : process . env . GITHUB_TOKEN } )
4341 . get ( `/repos/${ owner } /${ repo } ` )
4442 . reply ( 200 , { permissions : { push : true } } ) ;
4543
46- await t . notThrows ( promisify ( t . context . m . verifyConditions ) ( { } , { pkg , options} ) ) ;
44+ await t . notThrows ( t . context . m . verifyConditions ( { } , { options} ) ) ;
4745
4846 t . true ( github . isDone ( ) ) ;
4947} ) ;
@@ -52,14 +50,16 @@ test.serial('Verify Github auth with publish options', async t => {
5250 process . env . GITHUB_TOKEN = 'github_token' ;
5351 const owner = 'test_user' ;
5452 const repo = 'test_repo' ;
55- const options = { publish : { path : '@semantic-release/github' } } ;
56- const pkg = { name : 'package-name' , repository : { url : `git+https://othertesturl.com/${ owner } /${ repo } .git` } } ;
53+ const options = {
54+ publish : { path : '@semantic-release/github' } ,
55+ repositoryUrl : `git+https://othertesturl.com/${ owner } /${ repo } .git` ,
56+ } ;
5757
5858 const github = authenticate ( { githubToken : process . env . GITHUB_TOKEN } )
5959 . get ( `/repos/${ owner } /${ repo } ` )
6060 . reply ( 200 , { permissions : { push : true } } ) ;
6161
62- await t . notThrows ( promisify ( t . context . m . verifyConditions ) ( { } , { pkg , options} ) ) ;
62+ await t . notThrows ( t . context . m . verifyConditions ( { } , { options} ) ) ;
6363
6464 t . true ( github . isDone ( ) ) ;
6565} ) ;
@@ -69,14 +69,16 @@ test.serial('Verify Github auth and assets config', async t => {
6969 const owner = 'test_user' ;
7070 const repo = 'test_repo' ;
7171 const assets = [ { path : 'lib/file.js' } , 'file.js' ] ;
72- const options = { publish : [ { path : '@semantic-release/npm' } , { path : '@semantic-release/github' , assets} ] } ;
73- const pkg = { name : 'package-name' , repository : { url : `git+https://othertesturl.com/${ owner } /${ repo } .git` } } ;
72+ const options = {
73+ publish : [ { path : '@semantic-release/npm' } , { path : '@semantic-release/github' , assets} ] ,
74+ repositoryUrl : `git+https://othertesturl.com/${ owner } /${ repo } .git` ,
75+ } ;
7476
7577 const github = authenticate ( { githubToken : process . env . GH_TOKEN } )
7678 . get ( `/repos/${ owner } /${ repo } ` )
7779 . reply ( 200 , { permissions : { push : true } } ) ;
7880
79- await t . notThrows ( promisify ( t . context . m . verifyConditions ) ( { } , { pkg , options} ) ) ;
81+ await t . notThrows ( t . context . m . verifyConditions ( { } , { options} ) ) ;
8082
8183 t . true ( github . isDone ( ) ) ;
8284} ) ;
@@ -86,10 +88,12 @@ test.serial('Throw SemanticReleaseError if invalid config', async t => {
8688 const owner = 'test_user' ;
8789 const repo = 'test_repo' ;
8890 const assets = [ { wrongProperty : 'lib/file.js' } ] ;
89- const options = { publish : [ { path : '@semantic-release/npm' } , { path : '@semantic-release/github' , assets} ] } ;
90- const pkg = { name : 'package-name' , repository : { url : `git+https://othertesturl.com/${ owner } /${ repo } .git` } } ;
91+ const options = {
92+ publish : [ { path : '@semantic-release/npm' } , { path : '@semantic-release/github' , assets} ] ,
93+ repositoryUrl : `git+https://othertesturl.com/${ owner } /${ repo } .git` ,
94+ } ;
9195
92- const error = await t . throws ( promisify ( t . context . m . verifyConditions ) ( { } , { pkg , options} ) ) ;
96+ const error = await t . throws ( t . context . m . verifyConditions ( { } , { options} ) ) ;
9397
9498 t . true ( error instanceof SemanticReleaseError ) ;
9599 t . is ( error . code , 'EINVALIDASSETS' ) ;
@@ -104,8 +108,7 @@ test.serial('Publish a release with an array of assets', async t => {
104108 { path : 'test/fixtures/upload_other.txt' , name : 'other_file.txt' , label : 'Other File' } ,
105109 ] ;
106110 const nextRelease = { version : '1.0.0' , gitHead : '123' , gitTag : 'v1.0.0' , notes : 'Test release note body' } ;
107- const options = { branch : 'master' } ;
108- const pkg = { name : 'package-name' , repository : { url : `https://github.com/${ owner } /${ repo } .git` } } ;
111+ const options = { branch : 'master' , repositoryUrl : `https://github.com/${ owner } /${ repo } .git` } ;
109112 const releaseUrl = `https://github.com/${ owner } /${ repo } /releases/${ nextRelease . version } ` ;
110113 const assetUrl = `https://github.com/${ owner } /${ repo } /releases/download/${ nextRelease . version } /upload.txt` ;
111114 const otherAssetUrl = `https://github.com/${ owner } /${ repo } /releases/download/${ nextRelease . version } /other_file.txt` ;
@@ -134,7 +137,7 @@ test.serial('Publish a release with an array of assets', async t => {
134137 )
135138 . reply ( 200 , { browser_download_url : otherAssetUrl } ) ;
136139
137- await promisify ( t . context . m . publish ) ( { githubToken, assets} , { pkg , nextRelease, options, logger : t . context . logger } ) ;
140+ await t . context . m . publish ( { githubToken, assets} , { nextRelease, options, logger : t . context . logger } ) ;
138141
139142 t . true ( t . context . log . calledWith ( match . string , releaseUrl ) ) ;
140143 t . true ( t . context . log . calledWith ( match . string , assetUrl ) ) ;
@@ -151,10 +154,10 @@ test.serial('Verify Github auth and release', async t => {
151154 'test/fixtures/upload.txt' ,
152155 { path : 'test/fixtures/upload_other.txt' , name : 'other_file.txt' , label : 'Other File' } ,
153156 ] ;
154- const pkg = { name : 'package-name' , repository : { url : `https://github.com/${ owner } /${ repo } .git` } } ;
155157 const options = {
156158 publish : [ { path : '@semantic-release/npm' } , { path : '@semantic-release/github' , assets} ] ,
157159 branch : 'master' ,
160+ repositoryUrl : `https://github.com/${ owner } /${ repo } .git` ,
158161 } ;
159162 const nextRelease = { version : '1.0.0' , gitHead : '123' , gitTag : 'v1.0.0' , notes : 'Test release note body' } ;
160163 const releaseUrl = `https://github.com/${ owner } /${ repo } /releases/${ nextRelease . version } ` ;
@@ -185,8 +188,8 @@ test.serial('Verify Github auth and release', async t => {
185188 )
186189 . reply ( 200 , { browser_download_url : otherAssetUrl } ) ;
187190
188- await t . notThrows ( promisify ( t . context . m . verifyConditions ) ( { } , { pkg , options} ) ) ;
189- await promisify ( t . context . m . publish ) ( { assets} , { pkg , nextRelease, options, logger : t . context . logger } ) ;
191+ await t . notThrows ( t . context . m . verifyConditions ( { } , { options} ) ) ;
192+ await t . context . m . publish ( { assets} , { nextRelease, options, logger : t . context . logger } ) ;
190193
191194 t . true ( t . context . log . calledWith ( match . string , releaseUrl ) ) ;
192195 t . true ( t . context . log . calledWith ( match . string , assetUrl ) ) ;
0 commit comments