@@ -129,12 +129,44 @@ describe("invalid st2 credential configuration", function() {
129
129
} ) ;
130
130
131
131
// Load script under test
132
- var stackstorm = require ( "../scripts/stackstorm.js" ) ;
132
+ var i , stackstorm = require ( "../scripts/stackstorm.js" ) ;
133
133
stackstorm ( robot ) . then ( function ( stop ) {
134
134
expect ( info_spy ) . to . have . been . calledTwice ;
135
135
expect ( info_spy ) . to . have . been . calledWith ( 'Using ST2_API_KEY as authentication. Expiry will lead to bot exit.' ) ;
136
136
expect ( info_spy ) . to . have . been . calledWith ( 'Loading commands...' ) ;
137
137
138
+ // Check that it was called at some point with 'Failed to retrieve commands from'
139
+ for ( i = 0 ; i < error_spy . args . length ; i ++ ) {
140
+ try {
141
+ expect ( error_spy . args [ i ] [ 0 ] ) . to . be . a ( 'string' ) ;
142
+ expect ( error_spy . args [ i ] [ 0 ] ) . to . startWith ( 'StackStorm event stream error: Event { type: \'error\', status: 401 }' ) ;
143
+ break ;
144
+ } catch ( err ) {
145
+ // If we have reached the last call and we still haven't found it
146
+ if ( i >= error_spy . args . length - 1 ) {
147
+ // Re-throw the assert exception
148
+ throw ( err ) ;
149
+ }
150
+ // Implicit continue
151
+ }
152
+ }
153
+
154
+ // Check that it was called at some point with 'Failed to retrieve commands from'
155
+ for ( i = 0 ; i < error_spy . args . length ; i ++ ) {
156
+ try {
157
+ expect ( error_spy . args [ i ] [ 0 ] ) . to . be . a ( 'string' ) ;
158
+ expect ( error_spy ) . to . have . been . calledWith ( 'Implicitly attempting to reconnect to StackStorm event stream.' ) ;
159
+ break ;
160
+ } catch ( err ) {
161
+ // If we have reached the last call and we still haven't found it
162
+ if ( i >= error_spy . args . length - 1 ) {
163
+ // Re-throw the assert exception
164
+ throw ( err ) ;
165
+ }
166
+ // Implicit continue
167
+ }
168
+ }
169
+
138
170
stop ( { shutdown : true } ) ;
139
171
140
172
done ( ) ;
@@ -150,11 +182,42 @@ describe("invalid st2 credential configuration", function() {
150
182
} ) ;
151
183
152
184
// Load script under test
153
- var stackstorm = require ( "../scripts/stackstorm.js" ) ;
185
+ var i , stackstorm = require ( "../scripts/stackstorm.js" ) ;
154
186
stackstorm ( robot ) . then ( function ( stop ) {
155
187
expect ( info_spy ) . to . have . been . calledTwice ;
156
188
expect ( info_spy ) . to . have . been . calledWith ( 'Using ST2_AUTH_TOKEN as authentication. Expiry will lead to bot exit.' ) ;
157
- expect ( info_spy ) . to . have . been . calledWith ( 'Loading commands...' ) ;
189
+
190
+ // Check that it was called at some point with 'Failed to retrieve commands from'
191
+ for ( i = 0 ; i < error_spy . args . length ; i ++ ) {
192
+ try {
193
+ expect ( error_spy . args [ i ] [ 0 ] ) . to . be . a ( 'string' ) ;
194
+ expect ( error_spy . args [ i ] [ 0 ] ) . to . startWith ( 'StackStorm event stream error: Event { type: \'error\', status: 401 }' ) ;
195
+ break ;
196
+ } catch ( err ) {
197
+ // If we have reached the last call and we still haven't found it
198
+ if ( i >= error_spy . args . length - 1 ) {
199
+ // Re-throw the assert exception
200
+ throw ( err ) ;
201
+ }
202
+ // Implicit continue
203
+ }
204
+ }
205
+
206
+ // Check that it was called at some point with 'Failed to retrieve commands from'
207
+ for ( i = 0 ; i < error_spy . args . length ; i ++ ) {
208
+ try {
209
+ expect ( error_spy . args [ i ] [ 0 ] ) . to . be . a ( 'string' ) ;
210
+ expect ( error_spy ) . to . have . been . calledWith ( 'Implicitly attempting to reconnect to StackStorm event stream.' ) ;
211
+ break ;
212
+ } catch ( err ) {
213
+ // If we have reached the last call and we still haven't found it
214
+ if ( i >= error_spy . args . length - 1 ) {
215
+ // Re-throw the assert exception
216
+ throw ( err ) ;
217
+ }
218
+ // Implicit continue
219
+ }
220
+ }
158
221
159
222
stop ( { shutdown : true } ) ;
160
223
0 commit comments