@@ -291,7 +291,7 @@ func TestUpdateWithMixedResults(t *testing.T) {
291
291
if tk .APIStatus != "blocked" {
292
292
t .Fatal ("ApiStatus should be blocked" )
293
293
}
294
- if * tk .APIFailure != netxlite .FailureEOFError {
294
+ if len ( tk .APIFailure ) > 0 && tk . APIFailure [ 0 ] != netxlite .FailureEOFError {
295
295
t .Fatal ("invalid ApiFailure" )
296
296
}
297
297
if tk .FailingGateways != nil {
@@ -344,11 +344,24 @@ func TestInvalidCaCert(t *testing.T) {
344
344
if tk .APIStatus != "blocked" {
345
345
t .Fatal ("ApiStatus should be blocked" )
346
346
}
347
- if tk .FailingGateways != nil {
348
- t .Fatal ("invalid FailingGateways" )
347
+
348
+ if tk .FailingGateways == nil || len (tk .FailingGateways ) != 1 {
349
+ t .Fatal ("invalid length of FailingGateways" )
349
350
}
350
- if tk .TransportStatus != nil {
351
- t .Fatal ("invalid TransportStatus" )
351
+
352
+ gw := tk .FailingGateways [0 ]
353
+ if gw .IP != "234.345.234.345" {
354
+ t .Fatal ("invalid failed gateway ip: " + fmt .Sprint (gw .IP ))
355
+ }
356
+ if gw .Port != 443 {
357
+ t .Fatal ("invalid failed gateway port: " + fmt .Sprint (gw .Port ))
358
+ }
359
+ if gw .TransportType != "openvpn" {
360
+ t .Fatal ("invalid failed transport type: " + fmt .Sprint (gw .TransportType ))
361
+ }
362
+
363
+ if tk .TransportStatus == nil || tk .TransportStatus ["openvpn" ] != "ok" {
364
+ t .Fatal ("invalid TransportStatus: " + fmt .Sprint (tk .TransportStatus ))
352
365
}
353
366
}
354
367
@@ -371,17 +384,17 @@ func TestFailureCaCertFetch(t *testing.T) {
371
384
t .Fatal ("invalid ApiStatus" )
372
385
}
373
386
374
- if tk .APIFailure != nil {
375
- t .Fatal ("ApiFailure should be null" )
387
+ if tk .APIFailure == nil || len ( tk . APIFailure ) != 1 || tk . APIFailure [ 0 ] != io . EOF . Error () {
388
+ t .Fatal ("ApiFailure should not be null" + fmt . Sprint ( tk . APIFailure ) )
376
389
}
377
- if len (tk .Requests ) > 1 {
378
- t .Fatal ("Unexpected requests" )
390
+ if len (tk .Requests ) == 1 {
391
+ t .Fatal ("Too less requests, expected to run all API requests" )
379
392
}
380
393
if tk .FailingGateways != nil {
381
394
t .Fatal ("invalid FailingGateways" )
382
395
}
383
- if tk .TransportStatus != nil {
384
- t .Fatal ("invalid TransportStatus" )
396
+ if tk .TransportStatus == nil || tk . TransportStatus [ "openvpn" ] != "ok" || tk . TransportStatus [ "obfs4" ] != "ok" {
397
+ t .Fatal ("invalid TransportStatus: " + fmt . Sprint ( tk . TransportStatus ) )
385
398
}
386
399
}
387
400
0 commit comments