@@ -104,6 +104,47 @@ module.exports = () => {
104104 } ) ;
105105 } ) ;
106106
107+ // test
108+ tap . test ( 'Should deploy without auth but with token' , t => {
109+ // spy on console
110+ const consoleSpy = sinon . spy ( console , 'log' ) ;
111+ // copy original config for restoration
112+ const originalConfig = Object . assign ( { } , userConfig ) ;
113+
114+ // handle correct request
115+ const deployServer = nock ( 'http://localhost:8080' ) . post ( '/deploy' ) . reply ( ( uri , requestBody , cb ) => {
116+ cb ( null , [ 200 , { status : 'success' , deployments} ] ) ;
117+ } ) ;
118+
119+ // remove auth from config
120+ updateConfig ( { endpoint : 'http://localhost:8080' } ) ;
121+
122+ // execute login
123+ deploy ( { token : 'test-token' } ) . then ( ( ) => {
124+ // make sure log in was successful
125+ // check that server was called
126+ t . ok ( deployServer . isDone ( ) ) ;
127+ // first check console output
128+ t . deepEqual (
129+ consoleSpy . args ,
130+ [
131+ [ 'Deploying current project to endpoint:' , 'http://localhost:8080' ] ,
132+ [ 'Deploying using given token..' ] ,
133+ [ 'Your project is now deployed as:\n' ] ,
134+ [ ' ID URL Hostname \n test http://localhost test ' ] ,
135+ ] ,
136+ 'Correct log output'
137+ ) ;
138+ // restore console
139+ console . log . restore ( ) ;
140+ // tear down nock
141+ deployServer . done ( ) ;
142+ // restore original config
143+ updateConfig ( originalConfig ) ;
144+ t . end ( ) ;
145+ } ) ;
146+ } ) ;
147+
107148 // test
108149 tap . test ( 'Should not deploy with broken config' , t => {
109150 // spy on console
@@ -129,6 +170,29 @@ module.exports = () => {
129170 } ) ;
130171 } ) ;
131172
173+ // test
174+ tap . test ( 'Should not deploy with non-existent path' , t => {
175+ // spy on console
176+ const consoleSpy = sinon . spy ( console , 'log' ) ;
177+
178+ // execute deploy
179+ deploy ( { _ : [ 'i-do-not-exist' ] } ) . then ( ( ) => {
180+ // check console output
181+ t . deepEqual (
182+ consoleSpy . args ,
183+ [
184+ [ 'Deploying i-do-not-exist to endpoint:' , 'http://localhost:8080' ] ,
185+ [ `Error! Path ${ path . join ( process . cwd ( ) , 'i-do-not-exist' ) } do not exists` ] ,
186+ [ 'Please, check your arguments and try again.' ] ,
187+ ] ,
188+ 'Correct log output'
189+ ) ;
190+ // restore console
191+ console . log . restore ( ) ;
192+ t . end ( ) ;
193+ } ) ;
194+ } ) ;
195+
132196 // test
133197 tap . test ( 'Should deauth on 401' , t => {
134198 // copy original config for restoration
0 commit comments