Skip to content

Commit

Permalink
Fix test in go1.12
Browse files Browse the repository at this point in the history
go1.12 changes the error we get when an unsupported tls version is
required and so we need to fix the test to accomodate both pre go1.12
and post go1.12

This is done through go/build instead of through files with `// +build`
as the change is very local and this looks better and is more readable
in this particular case
  • Loading branch information
mstoykov committed Mar 12, 2019
1 parent 86bdde2 commit dd819cf
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion js/runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"crypto/tls"
"crypto/x509"
"fmt"
"go/build"
"io/ioutil"
stdlog "log"
"net"
Expand Down Expand Up @@ -824,6 +825,13 @@ func TestVUIntegrationHosts(t *testing.T) {
}

func TestVUIntegrationTLSConfig(t *testing.T) {
var unsupportedVersionErrorMsg = "remote error: tls: handshake failure"
for _, tag := range build.Default.ReleaseTags {
if tag == "go1.12" {
unsupportedVersionErrorMsg = "tls: no supported versions satisfy MinVersion and MaxVersion"
break
}
}
testdata := map[string]struct {
opts lib.Options
errMsg string
Expand All @@ -850,7 +858,7 @@ func TestVUIntegrationTLSConfig(t *testing.T) {
},
"UnsupportedVersion": {
lib.Options{TLSVersion: &lib.TLSVersions{Min: tls.VersionSSL30, Max: tls.VersionSSL30}},
"GoError: Get https://sha256.badssl.com/: remote error: tls: handshake failure",
"GoError: Get https://sha256.badssl.com/: " + unsupportedVersionErrorMsg,
},
}
for name, data := range testdata {
Expand Down

0 comments on commit dd819cf

Please sign in to comment.