Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

Commit

Permalink
Remove some less-necessary test helper functions
Browse files Browse the repository at this point in the history
  • Loading branch information
bboreham committed May 14, 2015
1 parent 3cd1a17 commit f6ac069
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 27 deletions.
2 changes: 1 addition & 1 deletion ipam/http_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func TestHttp(t *testing.T) {

// Ask the http server for another address and check it's different
cidr2 := HTTPPost(t, allocURL(port, container2))
wt.AssertNotEqualString(t, cidr2, testAddr1+netSuffix, "address")
wt.AssertFalse(t, cidr2 == testAddr1+netSuffix, "address")

// Ask for the first container again and we should get the same address again
cidr1a := HTTPPost(t, allocURL(port, containerID))
Expand Down
6 changes: 3 additions & 3 deletions ipam/space/space_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func TestSpaceAllocate(t *testing.T) {
space1.assertInvariants()

_, addr2 := space1.Allocate()
wt.AssertNotEqualString(t, addr2.String(), testAddr1, "address")
wt.AssertFalse(t, addr2.String() == testAddr1, "address")
wt.AssertEquals(t, space1.NumFreeAddresses(), address.Offset(18))
wt.AssertEquals(t, space1.NumFreeAddressesInRange(ip(testAddr1), ip(testAddrx)), address.Offset(13))
wt.AssertEquals(t, space1.NumFreeAddressesInRange(ip(testAddr1), ip(testAddry)), address.Offset(18))
Expand Down Expand Up @@ -194,7 +194,7 @@ func TestDonateSimple(t *testing.T) {

// Empty space set should split in two and give me the second half
start, numGivenUp, ok := ps1.Donate()
wt.AssertBool(t, ok, true, "Donate result")
wt.AssertTrue(t, ok, "Donate result")
wt.AssertEqualString(t, start.String(), "10.0.1.24", "Invalid start")
wt.AssertEquals(t, numGivenUp, address.Offset(24))
wt.AssertEquals(t, ps1.NumFreeAddresses(), address.Offset(24))
Expand Down Expand Up @@ -236,7 +236,7 @@ func TestDonateHard(t *testing.T) {

// Now split
newRange, numGivenUp, ok := spaceset.Donate()
wt.AssertBool(t, ok, true, "GiveUpSpace result")
wt.AssertTrue(t, ok, "GiveUpSpace result")
wt.AssertEquals(t, newRange, ip("10.0.1.23"))
wt.AssertEquals(t, numGivenUp, address.Offset(24))
wt.AssertEquals(t, spaceset.NumFreeAddresses(), address.Offset(23))
Expand Down
23 changes: 0 additions & 23 deletions testing/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,29 +40,12 @@ func AssertNoErr(t *testing.T, err error) {
}
}

func AssertBool(t *testing.T, got, wanted bool, desc string) {
if got != wanted {
Fatalf(t, "Expected %s %t but got %t", desc, wanted, got)
}
}

func AssertEqualUint32(t *testing.T, got, wanted uint32, desc string) {
if got != wanted {
Fatalf(t, "Expected %s %d but got %d", desc, wanted, got)
}
}

func AssertEqualuint64(t *testing.T, got, wanted uint64, desc string) {
if got != wanted {
Fatalf(t, "Expected %s %d but got %d", desc, wanted, got)
}
}

func AssertEqualInt64(t *testing.T, got, wanted int64, desc string) {
if got != wanted {
Fatalf(t, "Expected %s %d but got %d", desc, wanted, got)
}
}
func AssertEqualInt(t *testing.T, got, wanted int, desc string) {
if got != wanted {
Fatalf(t, "Expected %s %d but got %d", desc, wanted, got)
Expand All @@ -81,12 +64,6 @@ func AssertEqualString(t *testing.T, got, wanted string, desc string) {
}
}

func AssertNotEqualString(t *testing.T, got, wanted string, desc string) {
if got == wanted {
Fatalf(t, "Expected %s unlike '%s'", desc, wanted)
}
}

func AssertEquals(t *testing.T, a1, a2 interface{}) {
if !reflect.DeepEqual(a1, a2) {
Fatalf(t, "Expected %+v == %+v", a1, a2)
Expand Down

0 comments on commit f6ac069

Please sign in to comment.