Skip to content

Commit 854766b

Browse files
committed
Refactor retry interval execution for better readability
1 parent 92bd161 commit 854766b

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

pkg/runtime/runtime.go

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,7 @@ func Start(tests []TestCase, maxConcurrent int) <-chan TestResult {
125125
break
126126
}
127127

128-
if t.Command.GetRetries() > 1 && t.Command.Interval != "" {
129-
interval, err := time.ParseDuration(t.Command.Interval)
130-
if err != nil {
131-
panic(fmt.Sprintf("'%s' interval error: %s", t.Command.Cmd, err))
132-
}
133-
time.Sleep(interval)
134-
}
128+
executeRetryInterval(t)
135129
}
136130

137131
out <- result
@@ -147,6 +141,16 @@ func Start(tests []TestCase, maxConcurrent int) <-chan TestResult {
147141
return out
148142
}
149143

144+
func executeRetryInterval(t TestCase) {
145+
if t.Command.GetRetries() > 1 && t.Command.Interval != "" {
146+
interval, err := time.ParseDuration(t.Command.Interval)
147+
if err != nil {
148+
panic(fmt.Sprintf("'%s' interval error: %s", t.Command.Cmd, err))
149+
}
150+
time.Sleep(interval)
151+
}
152+
}
153+
150154
// runTest executes the current test case
151155
func runTest(test TestCase) TestResult {
152156
// cut = command under test

0 commit comments

Comments
 (0)