diff --git a/internal/experiment/openvpn/targets_test.go b/internal/experiment/openvpn/targets_test.go index 6ba2af988..480be65f5 100644 --- a/internal/experiment/openvpn/targets_test.go +++ b/internal/experiment/openvpn/targets_test.go @@ -13,24 +13,37 @@ func Test_resolveTarget(t *testing.T) { } _, err := resolveTarget("google.com") + if err != nil { + if err.Error() == "connection_refused" { + // connection_refused is raised when running this test + // on the restricted network for coverage tests. + // so we bail out + return + } t.Fatal("should be able to resolve the target") } _, err = resolveTarget("nothing.corp") if err == nil { - t.Fatal("should be able to resolve the target") + t.Fatal("should not be able to resolve the target") } _, err = resolveTarget("asfasfasfasfasfafs.ooni.io") if err == nil { - t.Fatal("should be able to resolve the target") + t.Fatal("should not be able to resolve the target") } } func Test_defaultOONIOpenVPNTargetUDP(t *testing.T) { url, err := defaultOONIOpenVPNTargetUDP() if err != nil { + if err.Error() == "connection_refused" { + // connection_refused is raised when running this test + // on the restricted network for coverage tests. + // so we bail out + return + } t.Fatal("unexpected error") } expected := "openvpn://oonivpn.corp/?address=37.218.243.98:1194&transport=udp" @@ -42,6 +55,12 @@ func Test_defaultOONIOpenVPNTargetUDP(t *testing.T) { func Test_defaultOONIOpenVPNTargetTCP(t *testing.T) { url, err := defaultOONIOpenVPNTargetTCP() if err != nil { + if err.Error() == "connection_refused" { + // connection_refused is raised when running this test + // on the restricted network for coverage tests. + // so we bail out + return + } t.Fatal("unexpected error") } expected := "openvpn://oonivpn.corp/?address=37.218.243.98:1194&transport=tcp"