network: update error check for Go 1.5

Changed upstream:
055ecb7be5
This commit is contained in:
Michael Marineau 2015-09-16 13:22:11 -07:00
parent c7f327bb89
commit 5405fc9d0d
3 changed files with 21 additions and 3 deletions

View File

@ -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)

View File

@ -0,0 +1,5 @@
// +build !go1.5
package network
const isGo15 = false

View File

@ -0,0 +1,5 @@
// +build go1.5
package network
const isGo15 = true