Skip to content

Commit

Permalink
Merge pull request #26 from rboyer/fix-build-failures
Browse files Browse the repository at this point in the history
Fix build failures affecting tests
  • Loading branch information
rboyer authored Jan 3, 2019
2 parents 555d50d + 0af07ac commit e92cdb5
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
22 changes: 17 additions & 5 deletions ifaddrs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"net"
"reflect"
"runtime"
"testing"

sockaddr "github.com/hashicorp/go-sockaddr"
Expand Down Expand Up @@ -1656,11 +1657,12 @@ func TestLimitOffset(t *testing.T) {

func TestSortIfBy(t *testing.T) {
tests := []struct {
name string
sortStr string
in sockaddr.IfAddrs
out sockaddr.IfAddrs
fail bool
name string
sortStr string
in sockaddr.IfAddrs
out sockaddr.IfAddrs
fail bool
skipWhen func() bool
}{
{
name: "sort address",
Expand Down Expand Up @@ -1729,6 +1731,9 @@ func TestSortIfBy(t *testing.T) {
// en0 has the default route.
name: "sort +default",
sortStr: "+default",
skipWhen: func() bool {
return runtime.GOOS != "darwin"
},
in: sockaddr.IfAddrs{
sockaddr.IfAddr{
SockAddr: sockaddr.MustIPv4Addr("1.2.3.4"),
Expand All @@ -1753,6 +1758,9 @@ func TestSortIfBy(t *testing.T) {
{
name: "sort -default",
sortStr: "-default",
skipWhen: func() bool {
return runtime.GOOS != "darwin"
},
in: sockaddr.IfAddrs{
sockaddr.IfAddr{
SockAddr: sockaddr.MustIPv4Addr("1.2.3.3"),
Expand Down Expand Up @@ -1965,6 +1973,10 @@ func TestSortIfBy(t *testing.T) {
if test.name == "" {
t.Fatalf("test %d needs a name", i)
}
if test.skipWhen != nil && test.skipWhen() {
t.SkipNow()
continue
}

t.Run(test.name, func(t *testing.T) {
sorted, err := sockaddr.SortIfBy(test.sortStr, test.in)
Expand Down
4 changes: 2 additions & 2 deletions ipv4addr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"testing"

"github.com/hashicorp/go-sockaddr"
sockaddr "github.com/hashicorp/go-sockaddr"
)

func TestSockAddr_IPv4Addr(t *testing.T) {
Expand Down Expand Up @@ -656,7 +656,7 @@ func TestSockAddr_IPv4Addr(t *testing.T) {
t.Errorf("[%d] Expected %+q's broadcast to be %+q, received %+q", idx, test.z00_input, test.z15_broadcast, b)
}

if p := ipv4.IPPort(); sockaddr.IPPort(p) != test.z16_portInt || sockaddr.IPPort(p) != test.z16_portInt {
if p := ipv4.IPPort(); sockaddr.IPPort(p) != test.z16_portInt {
t.Errorf("[%d] Expected %+q's port to be %d, received %d", idx, test.z00_input, test.z16_portInt, p)
}

Expand Down
4 changes: 2 additions & 2 deletions ipv6addr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"strings"
"testing"

"github.com/hashicorp/go-sockaddr"
sockaddr "github.com/hashicorp/go-sockaddr"
)

// ipv6HostMask is an unexported big.Int representing a /128 IPv6 address
Expand Down Expand Up @@ -427,7 +427,7 @@ func TestSockAddr_IPv6Addr(t *testing.T) {
t.Errorf("[%d] Expected %+q's LastUsable() to be %+q, received %+q", idx, test.z00_input, test.z14_lastUsable, l)
}

if p := ipv6.IPPort(); sockaddr.IPPort(p) != test.z16_portInt || sockaddr.IPPort(p) != test.z16_portInt {
if p := ipv6.IPPort(); sockaddr.IPPort(p) != test.z16_portInt {
t.Errorf("[%d] Expected %+q's port to be %+v, received %+v", idx, test.z00_input, test.z16_portInt, p)
}

Expand Down

0 comments on commit e92cdb5

Please sign in to comment.