Skip to content

Commit 6c2fee3

Browse files
committed
use table-based tests
1 parent 31f4771 commit 6c2fee3

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

pkg/mongo_client/config_test.go

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,21 @@ import (
77
)
88

99
func TestGetTimeout(t *testing.T) {
10+
t.Parallel()
1011
_ = os.Setenv("SOMEENV", "20s")
1112

12-
someEnv := getTimeout("SOMEENV", time.Second)
13-
if someEnv != 20 * time.Second {
14-
t.Errorf("want %s, got %s", "20s", someEnv)
13+
cases := [][]interface{}{
14+
{"SOMEENV", 20 * time.Second},
15+
{"NONEXIST", time.Second},
1516
}
1617

17-
otherEnv := getTimeout("NONEXIST", time.Second)
18-
if otherEnv != time.Second {
19-
t.Errorf("want %s, got %s", "20s", otherEnv)
18+
for _, tt := range cases {
19+
t.Run(tt[0].(string), func(t *testing.T) {
20+
t.Parallel()
21+
s := getTimeout(tt[0].(string), time.Second)
22+
if s != tt[1] {
23+
t.Errorf("got %q, want %q", s, tt[1])
24+
}
25+
})
2026
}
2127
}

0 commit comments

Comments
 (0)