Skip to content

Commit

Permalink
*: Don't pass testcase index to t.Run()
Browse files Browse the repository at this point in the history
The testing package already adds the test index if an empty string is
passed as the test name.
  • Loading branch information
a-robinson committed Dec 2, 2016
1 parent c81165c commit 0103e37
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
14 changes: 7 additions & 7 deletions pkg/storage/allocator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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),
}
Expand All @@ -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)
}
})
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/storage/replica_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions pkg/storage/timestamp_cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package storage

import (
"fmt"
"strconv"
"testing"
"time"

Expand Down Expand Up @@ -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).
Expand Down

0 comments on commit 0103e37

Please sign in to comment.