1
- import { promisify } from 'util' ;
2
1
import { escape } from 'querystring' ;
3
2
import test from 'ava' ;
4
3
import { stub , match } from 'sinon' ;
@@ -36,14 +35,13 @@ test.serial('Verify Github auth', async t => {
36
35
process . env . GITHUB_TOKEN = 'github_token' ;
37
36
const owner = 'test_user' ;
38
37
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` } ;
41
39
42
40
const github = authenticate ( { githubToken : process . env . GITHUB_TOKEN } )
43
41
. get ( `/repos/${ owner } /${ repo } ` )
44
42
. reply ( 200 , { permissions : { push : true } } ) ;
45
43
46
- await t . notThrows ( promisify ( t . context . m . verifyConditions ) ( { } , { pkg , options} ) ) ;
44
+ await t . notThrows ( t . context . m . verifyConditions ( { } , { options} ) ) ;
47
45
48
46
t . true ( github . isDone ( ) ) ;
49
47
} ) ;
@@ -52,14 +50,16 @@ test.serial('Verify Github auth with publish options', async t => {
52
50
process . env . GITHUB_TOKEN = 'github_token' ;
53
51
const owner = 'test_user' ;
54
52
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
+ } ;
57
57
58
58
const github = authenticate ( { githubToken : process . env . GITHUB_TOKEN } )
59
59
. get ( `/repos/${ owner } /${ repo } ` )
60
60
. reply ( 200 , { permissions : { push : true } } ) ;
61
61
62
- await t . notThrows ( promisify ( t . context . m . verifyConditions ) ( { } , { pkg , options} ) ) ;
62
+ await t . notThrows ( t . context . m . verifyConditions ( { } , { options} ) ) ;
63
63
64
64
t . true ( github . isDone ( ) ) ;
65
65
} ) ;
@@ -69,14 +69,16 @@ test.serial('Verify Github auth and assets config', async t => {
69
69
const owner = 'test_user' ;
70
70
const repo = 'test_repo' ;
71
71
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
+ } ;
74
76
75
77
const github = authenticate ( { githubToken : process . env . GH_TOKEN } )
76
78
. get ( `/repos/${ owner } /${ repo } ` )
77
79
. reply ( 200 , { permissions : { push : true } } ) ;
78
80
79
- await t . notThrows ( promisify ( t . context . m . verifyConditions ) ( { } , { pkg , options} ) ) ;
81
+ await t . notThrows ( t . context . m . verifyConditions ( { } , { options} ) ) ;
80
82
81
83
t . true ( github . isDone ( ) ) ;
82
84
} ) ;
@@ -86,10 +88,12 @@ test.serial('Throw SemanticReleaseError if invalid config', async t => {
86
88
const owner = 'test_user' ;
87
89
const repo = 'test_repo' ;
88
90
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
+ } ;
91
95
92
- const error = await t . throws ( promisify ( t . context . m . verifyConditions ) ( { } , { pkg , options} ) ) ;
96
+ const error = await t . throws ( t . context . m . verifyConditions ( { } , { options} ) ) ;
93
97
94
98
t . true ( error instanceof SemanticReleaseError ) ;
95
99
t . is ( error . code , 'EINVALIDASSETS' ) ;
@@ -104,8 +108,7 @@ test.serial('Publish a release with an array of assets', async t => {
104
108
{ path : 'test/fixtures/upload_other.txt' , name : 'other_file.txt' , label : 'Other File' } ,
105
109
] ;
106
110
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` } ;
109
112
const releaseUrl = `https://github.com/${ owner } /${ repo } /releases/${ nextRelease . version } ` ;
110
113
const assetUrl = `https://github.com/${ owner } /${ repo } /releases/download/${ nextRelease . version } /upload.txt` ;
111
114
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 => {
134
137
)
135
138
. reply ( 200 , { browser_download_url : otherAssetUrl } ) ;
136
139
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 } ) ;
138
141
139
142
t . true ( t . context . log . calledWith ( match . string , releaseUrl ) ) ;
140
143
t . true ( t . context . log . calledWith ( match . string , assetUrl ) ) ;
@@ -151,10 +154,10 @@ test.serial('Verify Github auth and release', async t => {
151
154
'test/fixtures/upload.txt' ,
152
155
{ path : 'test/fixtures/upload_other.txt' , name : 'other_file.txt' , label : 'Other File' } ,
153
156
] ;
154
- const pkg = { name : 'package-name' , repository : { url : `https://github.com/${ owner } /${ repo } .git` } } ;
155
157
const options = {
156
158
publish : [ { path : '@semantic-release/npm' } , { path : '@semantic-release/github' , assets} ] ,
157
159
branch : 'master' ,
160
+ repositoryUrl : `https://github.com/${ owner } /${ repo } .git` ,
158
161
} ;
159
162
const nextRelease = { version : '1.0.0' , gitHead : '123' , gitTag : 'v1.0.0' , notes : 'Test release note body' } ;
160
163
const releaseUrl = `https://github.com/${ owner } /${ repo } /releases/${ nextRelease . version } ` ;
@@ -185,8 +188,8 @@ test.serial('Verify Github auth and release', async t => {
185
188
)
186
189
. reply ( 200 , { browser_download_url : otherAssetUrl } ) ;
187
190
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 } ) ;
190
193
191
194
t . true ( t . context . log . calledWith ( match . string , releaseUrl ) ) ;
192
195
t . true ( t . context . log . calledWith ( match . string , assetUrl ) ) ;
0 commit comments