Skip to content

Commit abdb914

Browse files
authored
Merge pull request #48 from jaypipes/timeout-conflict
fix TimeoutConflict error message
2 parents b2b65f2 + a21aaf4 commit abdb914

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

api/error.go

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -315,27 +315,31 @@ func RequiredFixtureMissing(name string) error {
315315
func TimeoutConflict(
316316
ti *Timings,
317317
) error {
318-
gotestDeadline := ti.GoTestTimeout
318+
goTestTimeout := ti.GoTestTimeout
319319
totalWait := ti.TotalWait
320320
maxTimeout := ti.MaxTimeout
321321
msg := fmt.Sprintf(
322322
"go test -timeout value of %s ",
323-
(gotestDeadline + time.Second).Round(time.Second),
323+
(goTestTimeout + time.Second).Round(time.Second),
324324
)
325325
if totalWait > 0 {
326-
msg += fmt.Sprintf(
327-
"is shorter than the total wait time in the scenario: %s. "+
328-
"either decrease the wait times or increase the "+
329-
"go test -timeout value.",
330-
totalWait.Round(time.Second),
331-
)
326+
if totalWait.Abs() > goTestTimeout.Abs() {
327+
msg += fmt.Sprintf(
328+
"is shorter than the total wait time in the scenario: %s. "+
329+
"either decrease the wait times or increase the "+
330+
"go test -timeout value.",
331+
totalWait.Round(time.Second),
332+
)
333+
}
332334
} else {
333-
msg += fmt.Sprintf(
334-
"is shorter than the maximum timeout specified in the "+
335-
"scenario: %s. either decrease the scenario or spec "+
336-
"timeout or increase the go test -timeout value.",
337-
maxTimeout.Round(time.Second),
338-
)
335+
if maxTimeout.Abs() > goTestTimeout.Abs() {
336+
msg += fmt.Sprintf(
337+
"is shorter than the maximum timeout specified in the "+
338+
"scenario: %s. either decrease the scenario or spec "+
339+
"timeout or increase the go test -timeout value.",
340+
maxTimeout.Round(time.Second),
341+
)
342+
}
339343
}
340344
return fmt.Errorf("%w: %s", ErrTimeoutConflict, msg)
341345
}

0 commit comments

Comments
 (0)