Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix build failures affecting tests #26

Merged
merged 2 commits into from
Jan 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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