From 5405fc9d0d5f196ce073be1e4f8fd325fc400c25 Mon Sep 17 00:00:00 2001 From: Michael Marineau Date: Wed, 16 Sep 2015 13:22:11 -0700 Subject: [PATCH] network: update error check for Go 1.5 Changed upstream: https://github.com/golang/go/commit/055ecb7be5805e07498488c59c6f01644fdacccc --- network/digitalocean_test.go | 14 +++++++++++--- network/is_go15_false_test.go | 5 +++++ network/is_go15_true_test.go | 5 +++++ 3 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 network/is_go15_false_test.go create mode 100644 network/is_go15_true_test.go diff --git a/network/digitalocean_test.go b/network/digitalocean_test.go index 381ce2c..ec07c9b 100644 --- a/network/digitalocean_test.go +++ b/network/digitalocean_test.go @@ -52,6 +52,14 @@ func TestParseNameservers(t *testing.T) { } } +func mkInvalidMAC() error { + if isGo15 { + return &net.AddrError{Err: "invalid MAC address", Addr: "bad"} + } else { + return errors.New("invalid MAC address: bad") + } +} + func TestParseInterface(t *testing.T) { for _, tt := range []struct { cfg digitalocean.Interface @@ -64,7 +72,7 @@ func TestParseInterface(t *testing.T) { cfg: digitalocean.Interface{ MAC: "bad", }, - err: errors.New("invalid MAC address: bad"), + err: mkInvalidMAC(), }, { cfg: digitalocean.Interface{ @@ -337,13 +345,13 @@ func TestParseInterfaces(t *testing.T) { cfg: digitalocean.Interfaces{ Public: []digitalocean.Interface{{MAC: "bad"}}, }, - err: errors.New("invalid MAC address: bad"), + err: mkInvalidMAC(), }, { cfg: digitalocean.Interfaces{ Private: []digitalocean.Interface{{MAC: "bad"}}, }, - err: errors.New("invalid MAC address: bad"), + err: mkInvalidMAC(), }, } { ifaces, err := parseInterfaces(tt.cfg, tt.nss) diff --git a/network/is_go15_false_test.go b/network/is_go15_false_test.go new file mode 100644 index 0000000..85d5f0d --- /dev/null +++ b/network/is_go15_false_test.go @@ -0,0 +1,5 @@ +// +build !go1.5 + +package network + +const isGo15 = false diff --git a/network/is_go15_true_test.go b/network/is_go15_true_test.go new file mode 100644 index 0000000..953836d --- /dev/null +++ b/network/is_go15_true_test.go @@ -0,0 +1,5 @@ +// +build go1.5 + +package network + +const isGo15 = true