فهرست منبع

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) {