Remove some less-necessary test helper functions
This commit is contained in:
1 parent
3cd1a17c23
commit
f6ac069bc5
3 files changed
+4
-27
No files matched your search
+1
-1
@@ -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))
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in new issue
Block a user