@@ -49,6 +49,21 @@ var providerConfig = {
4949 auth : { type : 'ssh' }
5050} ;
5151
52+ var providerConfigForProjectWithMissingStriderJson =
53+ { whitelist : [ ] ,
54+ pull_requests : 'none' ,
55+ repo : 'http://nodev/stridertester/priproject2' ,
56+ owner :
57+ { avatar_url : 'http://www.gravatar.com/avatar/3f671ed86ed3d21ed3640c7a016b0997?s=40&d=identicon' ,
58+ state : 'active' ,
59+ id : 3 ,
60+ username : 'stridertester' ,
61+ name : 'Strider Tester' } ,
62+ url : 'git@nodev:stridertester/priproject2.git' ,
63+ scm : 'git' ,
64+ auth : { type : 'ssh' }
65+ } ;
66+
5267var repoProject = {
5368 name : 'stridertester/privproject1' ,
5469 display_name : 'stridertester/privproject1' ,
@@ -127,35 +142,51 @@ describe('gitlab webapp', function () {
127142 nock . cleanAll ( ) ;
128143 } ) ;
129144
145+ var filename = "strider.json" ;
130146
131- it ( 'should get a json file correctly' , function ( done ) {
132- var filename = "strider.json" ;
147+ var ref = {
148+ branch : 'master' ,
149+ } ;
133150
134- var ref = {
135- branch : 'master' ,
136- } ;
151+ //getFile only uses account.config
152+ var account = {
153+ config : {
154+ api_key : 'zRtVsmeznn7ySatTrnrp' ,
155+ api_url : 'http://localhost:80/api/v3'
156+ }
157+ } ;
137158
138- //getFile only uses account.config
139- var account = {
140- config : {
141- api_key : 'zRtVsmeznn7ySatTrnrp' ,
142- api_url : 'http://localhost:80/api/v3'
143- }
144- } ;
145159
160+ //getFile only uses project.provider.repo_id
161+ var project = {
162+ provider : {
163+ repo_id : '5'
164+ }
165+ } ;
146166
147- //getFile only uses project.provider.repo_id
148- var project = {
149- provider : {
150- repo_id : '5' ,
151- }
167+ //project with strider.json missing
168+ var projectWithMissingStriderJson = {
169+ provider : {
170+ repo_id : '8'
152171 }
172+ } ;
173+
153174
175+ it ( 'should get a json file correctly' , function ( done ) {
154176 webapp . getFile ( filename , ref , account , providerConfig , project , function ( err , text ) {
155177 expect ( text ) . to . be . a ( 'string' ) ;
156178 done ( ) ;
157179 } ) ;
158180 } ) ;
181+
182+ //created a project priproject2 of type node.js, but not having a strider.json for this test
183+ it ( 'should not crash, but return an error if the file could not be found' , function ( done ) {
184+ webapp . getFile ( filename , ref , account , providerConfigForProjectWithMissingStriderJson , projectWithMissingStriderJson , function ( err , text ) {
185+ expect ( err ) . to . be . ok ( ) ;
186+ expect ( text ) . to . not . be . ok ( ) ;
187+ done ( ) ;
188+ } ) ;
189+ } ) ;
159190 } ) ;
160191
161192 //--------------------------------------------------------------------------------------
0 commit comments