From f6ac069bc52d697c441663c1e72dd8d675b160dd Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Thu, 14 May 2015 17:57:13 +0100 Subject: [PATCH] Remove some less-necessary test helper functions --- ipam/http_test.go | 2 +- ipam/space/space_test.go | 6 +++--- testing/util.go | 23 ----------------------- 3 files changed, 4 insertions(+), 27 deletions(-) diff --git a/ipam/http_test.go b/ipam/http_test.go index 710bb4fb..a42bf5ba 100644 --- a/ipam/http_test.go +++ b/ipam/http_test.go @@ -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)) diff --git a/ipam/space/space_test.go b/ipam/space/space_test.go index fd13c42c..d49324b7 100644 --- a/ipam/space/space_test.go +++ b/ipam/space/space_test.go @@ -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)) @@ -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)) @@ -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)) diff --git a/testing/util.go b/testing/util.go index c637eff5..1e45685a 100644 --- a/testing/util.go +++ b/testing/util.go @@ -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) @@ -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)