@@ -648,25 +648,26 @@ func TestVUIntegrationInsecureRequests(t *testing.T) {
648
648
}{
649
649
"Null" : {
650
650
lib.Options {},
651
- "GoError: Get https://expired.badssl.com/: x509: certificate has expired or is not yet valid" ,
651
+ "x509: certificate has expired or is not yet valid" ,
652
652
},
653
653
"False" : {
654
654
lib.Options {InsecureSkipTLSVerify : null .BoolFrom (false )},
655
- "GoError: Get https://expired.badssl.com/: x509: certificate has expired or is not yet valid" ,
655
+ "x509: certificate has expired or is not yet valid" ,
656
656
},
657
657
"True" : {
658
658
lib.Options {InsecureSkipTLSVerify : null .BoolFrom (true )},
659
659
"" ,
660
660
},
661
661
}
662
662
for name , data := range testdata {
663
+ data := data
663
664
t .Run (name , func (t * testing.T ) {
664
665
r1 , err := getSimpleRunner ("/script.js" , `
665
666
import http from "k6/http";
666
667
export default function() { http.get("https://expired.badssl.com/"); }
667
668
` )
668
669
require .NoError (t , err )
669
- r1 .SetOptions (lib.Options {Throw : null .BoolFrom (true )}.Apply (data .opts ))
670
+ require . NoError ( t , r1 .SetOptions (lib.Options {Throw : null .BoolFrom (true )}.Apply (data .opts ) ))
670
671
671
672
r2 , err := NewFromArchive (r1 .MakeArchive (), lib.RuntimeOptions {})
672
673
require .NoError (t , err )
@@ -681,7 +682,8 @@ func TestVUIntegrationInsecureRequests(t *testing.T) {
681
682
}
682
683
err = vu .RunOnce (context .Background ())
683
684
if data .errMsg != "" {
684
- assert .EqualError (t , err , data .errMsg )
685
+ require .NotNil (t , err )
686
+ assert .Contains (t , err .Error (), data .errMsg )
685
687
} else {
686
688
assert .NoError (t , err )
687
689
}
@@ -703,10 +705,10 @@ func TestVUIntegrationBlacklistOption(t *testing.T) {
703
705
if ! assert .NoError (t , err ) {
704
706
return
705
707
}
706
- r1 .SetOptions (lib.Options {
708
+ require . NoError ( t , r1 .SetOptions (lib.Options {
707
709
Throw : null .BoolFrom (true ),
708
710
BlacklistIPs : []* lib.IPNet {cidr },
709
- })
711
+ }))
710
712
711
713
r2 , err := NewFromArchive (r1 .MakeArchive (), lib.RuntimeOptions {})
712
714
if ! assert .NoError (t , err ) {
@@ -721,7 +723,8 @@ func TestVUIntegrationBlacklistOption(t *testing.T) {
721
723
return
722
724
}
723
725
err = vu .RunOnce (context .Background ())
724
- assert .EqualError (t , err , "GoError: Get http://10.1.2.3/: IP (10.1.2.3) is in a blacklisted range (10.0.0.0/8)" )
726
+ require .NotNil (t , err )
727
+ assert .Contains (t , err .Error (), "IP (10.1.2.3) is in a blacklisted range (10.0.0.0/8)" )
725
728
})
726
729
}
727
730
}
@@ -756,7 +759,8 @@ func TestVUIntegrationBlacklistScript(t *testing.T) {
756
759
return
757
760
}
758
761
err = vu .RunOnce (context .Background ())
759
- assert .EqualError (t , err , "GoError: Get http://10.1.2.3/: IP (10.1.2.3) is in a blacklisted range (10.0.0.0/8)" )
762
+ require .NotNil (t , err )
763
+ assert .Contains (t , err .Error (), "IP (10.1.2.3) is in a blacklisted range (10.0.0.0/8)" )
760
764
})
761
765
}
762
766
}
@@ -830,7 +834,7 @@ func TestVUIntegrationTLSConfig(t *testing.T) {
830
834
},
831
835
"UnsupportedCipherSuite" : {
832
836
lib.Options {TLSCipherSuites : & lib.TLSCipherSuites {tls .TLS_RSA_WITH_RC4_128_SHA }},
833
- "GoError: Get https://sha256.badssl.com/: remote error: tls: handshake failure" ,
837
+ "remote error: tls: handshake failure" ,
834
838
},
835
839
"NullVersion" : {
836
840
lib.Options {},
@@ -842,10 +846,11 @@ func TestVUIntegrationTLSConfig(t *testing.T) {
842
846
},
843
847
"UnsupportedVersion" : {
844
848
lib.Options {TLSVersion : & lib.TLSVersions {Min : tls .VersionSSL30 , Max : tls .VersionSSL30 }},
845
- "GoError: Get https://sha256.badssl.com/: " + unsupportedVersionErrorMsg ,
849
+ unsupportedVersionErrorMsg ,
846
850
},
847
851
}
848
852
for name , data := range testdata {
853
+ data := data
849
854
t .Run (name , func (t * testing.T ) {
850
855
r1 , err := getSimpleRunner ("/script.js" , `
851
856
import http from "k6/http";
@@ -854,7 +859,7 @@ func TestVUIntegrationTLSConfig(t *testing.T) {
854
859
if ! assert .NoError (t , err ) {
855
860
return
856
861
}
857
- r1 .SetOptions (lib.Options {Throw : null .BoolFrom (true )}.Apply (data .opts ))
862
+ require . NoError ( t , r1 .SetOptions (lib.Options {Throw : null .BoolFrom (true )}.Apply (data .opts ) ))
858
863
859
864
r2 , err := NewFromArchive (r1 .MakeArchive (), lib.RuntimeOptions {})
860
865
if ! assert .NoError (t , err ) {
@@ -872,7 +877,8 @@ func TestVUIntegrationTLSConfig(t *testing.T) {
872
877
}
873
878
err = vu .RunOnce (context .Background ())
874
879
if data .errMsg != "" {
875
- assert .EqualError (t , err , data .errMsg )
880
+ require .NotNil (t , err )
881
+ assert .Contains (t , err .Error (), data .errMsg )
876
882
} else {
877
883
assert .NoError (t , err )
878
884
}
@@ -894,10 +900,10 @@ func TestVUIntegrationHTTP2(t *testing.T) {
894
900
if ! assert .NoError (t , err ) {
895
901
return
896
902
}
897
- r1 .SetOptions (lib.Options {
903
+ require . NoError ( t , r1 .SetOptions (lib.Options {
898
904
Throw : null .BoolFrom (true ),
899
905
SystemTags : stats .NewSystemTagSet (stats .TagProto ),
900
- })
906
+ }))
901
907
902
908
r2 , err := NewFromArchive (r1 .MakeArchive (), lib.RuntimeOptions {})
903
909
if ! assert .NoError (t , err ) {
@@ -1150,10 +1156,10 @@ func TestVUIntegrationClientCerts(t *testing.T) {
1150
1156
if ! assert .NoError (t , err ) {
1151
1157
return
1152
1158
}
1153
- r1 .SetOptions (lib.Options {
1159
+ require . NoError ( t , r1 .SetOptions (lib.Options {
1154
1160
Throw : null .BoolFrom (true ),
1155
1161
InsecureSkipTLSVerify : null .BoolFrom (true ),
1156
- })
1162
+ }))
1157
1163
1158
1164
t .Run ("Unauthenticated" , func (t * testing.T ) {
1159
1165
r2 , err := NewFromArchive (r1 .MakeArchive (), lib.RuntimeOptions {})
@@ -1175,7 +1181,7 @@ func TestVUIntegrationClientCerts(t *testing.T) {
1175
1181
}
1176
1182
})
1177
1183
1178
- r1 .SetOptions (lib.Options {
1184
+ require . NoError ( t , r1 .SetOptions (lib.Options {
1179
1185
TLSAuth : []* lib.TLSAuth {
1180
1186
{
1181
1187
TLSAuthFields : lib.TLSAuthFields {
@@ -1199,7 +1205,7 @@ func TestVUIntegrationClientCerts(t *testing.T) {
1199
1205
},
1200
1206
},
1201
1207
},
1202
- })
1208
+ }))
1203
1209
1204
1210
t .Run ("Authenticated" , func (t * testing.T ) {
1205
1211
r2 , err := NewFromArchive (r1 .MakeArchive (), lib.RuntimeOptions {})
0 commit comments