From 0103e37812abdf2472f652ba09cc5549dca9143a Mon Sep 17 00:00:00 2001 From: Alex Robinson Date: Fri, 2 Dec 2016 15:20:21 -0500 Subject: [PATCH] *: Don't pass testcase index to t.Run() The testing package already adds the test index if an empty string is passed as the test name. --- pkg/storage/allocator_test.go | 14 +++++++------- pkg/storage/replica_test.go | 4 ++-- pkg/storage/timestamp_cache_test.go | 5 ++--- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/pkg/storage/allocator_test.go b/pkg/storage/allocator_test.go index 9135e369b5ae..cbaf8646e66e 100644 --- a/pkg/storage/allocator_test.go +++ b/pkg/storage/allocator_test.go @@ -990,8 +990,8 @@ func TestAllocatorTransferLeaseTarget(t *testing.T) { {existing: existing, leaseholder: 3, check: true, expected: 1}, {existing: existing, leaseholder: 3, check: false, expected: 1}, } - for i, c := range testCases { - t.Run(fmt.Sprintf("%d", i), func(t *testing.T) { + for _, c := range testCases { + t.Run("", func(t *testing.T) { target := a.TransferLeaseTarget(config.Constraints{}, c.existing, c.leaseholder, 0, c.check) if c.expected != target.StoreID { @@ -1053,8 +1053,8 @@ func TestAllocatorShouldTransferLease(t *testing.T) { {leaseholder: 3, existing: replicas(4), expected: false}, {leaseholder: 4, existing: nil, expected: true}, } - for i, c := range testCases { - t.Run(fmt.Sprintf("%d", i), func(t *testing.T) { + for _, c := range testCases { + t.Run("", func(t *testing.T) { result := a.ShouldTransferLease(config.Constraints{}, c.existing, c.leaseholder, 0) if c.expected != result { t.Fatalf("expected %v, but found %v", c.expected, result) @@ -1695,8 +1695,8 @@ func TestFilterBehindReplicas(t *testing.T) { {[]uint64{1, 2, 3, 4, 5}, []uint64{3, 4, 5}}, {[]uint64{6, 5, 4, 3, 2}, []uint64{6, 5, 4}}, } - for i, c := range testCases { - t.Run(fmt.Sprintf("%d", i), func(t *testing.T) { + for _, c := range testCases { + t.Run("", func(t *testing.T) { status := &raft.Status{ Progress: make(map[uint64]raft.Progress), } @@ -1714,7 +1714,7 @@ func TestFilterBehindReplicas(t *testing.T) { ids = append(ids, uint64(c.StoreID)) } if !reflect.DeepEqual(c.expected, ids) { - t.Fatalf("%d: expected %d, but got %d", i, c.expected, ids) + t.Fatalf("expected %d, but got %d", c.expected, ids) } }) } diff --git a/pkg/storage/replica_test.go b/pkg/storage/replica_test.go index 3896fd1b97b6..2f5a29f9c86f 100644 --- a/pkg/storage/replica_test.go +++ b/pkg/storage/replica_test.go @@ -6054,8 +6054,8 @@ func TestSetReplicaID(t *testing.T) { {1, 2, 1, ""}, // not an error; replicaID == newReplicaID is checked first {2, 0, 1, "replicaID cannot move backwards"}, } - for i, c := range testCases { - t.Run(fmt.Sprintf("%d", i), func(t *testing.T) { + for _, c := range testCases { + t.Run("", func(t *testing.T) { repl.mu.Lock() repl.mu.replicaID = c.replicaID repl.mu.minReplicaID = c.minReplicaID diff --git a/pkg/storage/timestamp_cache_test.go b/pkg/storage/timestamp_cache_test.go index 197fbba96d05..ecc543796557 100644 --- a/pkg/storage/timestamp_cache_test.go +++ b/pkg/storage/timestamp_cache_test.go @@ -18,7 +18,6 @@ package storage import ( "fmt" - "strconv" "testing" "time" @@ -464,14 +463,14 @@ func TestTimestampCacheLayeredIntervals(t *testing.T) { tc := newTimestampCache(clock) // Run each test case in several configurations. - for testCaseIdx, testCase := range []layeredIntervalTestCase{ + for _, testCase := range []layeredIntervalTestCase{ layeredIntervalTestCase1, layeredIntervalTestCase2, layeredIntervalTestCase3, layeredIntervalTestCase4, layeredIntervalTestCase5, } { - t.Run(strconv.Itoa(testCaseIdx), func(t *testing.T) { + t.Run("", func(t *testing.T) { // In simultaneous runs, each span in the test case is given the same // time. Otherwise each gets a distinct timestamp (in the order of // definition).