Clarify some unit test operations

This commit is contained in:
Bryan Boreham committed 2015-06-10 17:24:36 +01:00
1 parent 6536034ab6
commit 147962d101
2 files changed
+7 -7

No files matched your search

+2 -2
View File
@@ -38,13 +38,13 @@ func TestAllocFree(t *testing.T) {
_, cidr2, _ := address.ParseCIDR(subnet2)
alloc.claimRingForTesting()
addr1, _ := alloc.Allocate(container1, cidr1, nil)
addr1, err := alloc.Allocate(container1, cidr1, nil)
wt.AssertNoErr(t, err)
wt.AssertEqualString(t, addr1.String(), testAddr1, "address")
addr2, err := alloc.Allocate(container1, cidr2, nil)
wt.AssertNoErr(t, err)
wt.AssertEqualString(t, addr2.String(), testAddr2, "address")
CheckAllExpectedMessagesSent(alloc)
// Ask for another address for a different container and check it's different
addr1b, _ := alloc.Allocate(container2, cidr1, nil)
+5 -5
View File
@@ -74,22 +74,22 @@ func TestHttp(t *testing.T) {
container2 = "baddf00d"
container3 = "b01df00d"
universe = "10.0.0.0/8"
testAddr1 = "10.0.3.9/29"
testCIDR1 = "10.0.3.8/29"
testCIDR2 = "10.2.0.0/16"
testAddr1 = "10.0.3.9/29"
testAddr2 = "10.2.0.1/16"
)
alloc, subnet := makeAllocatorWithMockGossip(t, "08:00:27:01:c3:9a", universe, 1)
port := listenHTTP(alloc, subnet)
alloc.claimRingForTesting()
// Allocate an address in each subnet, and check we got what we expected
cidr1a := HTTPPost(t, allocURL(port, testCIDR1, containerID))
wt.AssertEqualString(t, cidr1a, testAddr1, "address")
cidr2a := HTTPPost(t, allocURL(port, testCIDR2, containerID))
wt.AssertEqualString(t, cidr2a, testAddr2, "address")
// Now, make the same requests again to check the operation is idempotent
check := HTTPGet(t, allocURL(port, testCIDR1, containerID))
wt.AssertEqualString(t, check, cidr1a, "address")
check = HTTPGet(t, allocURL(port, testCIDR2, containerID))
@@ -101,7 +101,7 @@ func TestHttp(t *testing.T) {
cidr2b := HTTPPost(t, allocURL(port, testCIDR2, container2))
wt.AssertFalse(t, cidr2b == testAddr2, "address")
// Now free the first container, and we should get it back when we ask
// Now free the first container, and we should get its addresses back when we ask
doHTTP("DELETE", identURL(port, containerID))
cidr1c := HTTPPost(t, allocURL(port, testCIDR1, container3))