浏览代码

test: update tests to use sub-benchmarks

Go 1.7 added the subtest feature which can make table-driven tests much easier to run and debug. Some tests are not using this feature.

Signed-off-by: Yang Li <idealhack@gmail.com>
Yang Li 7 年之前
父节点
当前提交
b0b5e14b77
共有 1 个文件被更改,包括 13 次插入11 次删除
  1. 13 11
      libnetwork/ipam/allocator_test.go

+ 13 - 11
libnetwork/ipam/allocator_test.go

@@ -1141,19 +1141,21 @@ func benchMarkRequest(subnet string, b *testing.B) {
 	}
 	}
 }
 }
 
 
-func BenchmarkRequest_24(b *testing.B) {
-	a, _ := getAllocator(true)
-	benchmarkRequest(b, a, "10.0.0.0/24")
-}
+func BenchmarkRequest(b *testing.B) {
 
 
-func BenchmarkRequest_16(b *testing.B) {
-	a, _ := getAllocator(true)
-	benchmarkRequest(b, a, "10.0.0.0/16")
-}
+	subnets := []string{
+		"10.0.0.0/24",
+		"10.0.0.0/16",
+		"10.0.0.0/8",
+	}
 
 
-func BenchmarkRequest_8(b *testing.B) {
-	a, _ := getAllocator(true)
-	benchmarkRequest(b, a, "10.0.0.0/8")
+	for _, subnet := range subnets {
+		name := fmt.Sprintf("%vSubnet", subnet)
+		b.Run(name, func(b *testing.B) {
+			a, _ := getAllocator(true)
+			benchmarkRequest(b, a, subnet)
+		})
+	}
 }
 }
 
 
 func TestAllocateRandomDeallocate(t *testing.T) {
 func TestAllocateRandomDeallocate(t *testing.T) {