Skip to content

Commit b5c7162

Browse files
committed
Extend Be to Run
1 parent c34ad4a commit b5c7162

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

be/assert.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,21 @@ import (
88

99
type Outcome string
1010

11+
type Failer interface {
12+
Fatal(args ...any)
13+
}
14+
15+
func (o *Outcome) Run(t Failer, msg string, args ...any) {
16+
if o == nil {
17+
return
18+
}
19+
if len(args) > 0 {
20+
msg = fmt.Sprintf(msg, args...)
21+
}
22+
fullMsg := fmt.Sprintf("%s: %s", msg, *o)
23+
t.Fatal(fullMsg)
24+
}
25+
1126
func failf(format string, args ...any) *Outcome {
1227
str := fmt.Sprintf(format, args...)
1328
return (*Outcome)(&str)

0 commit comments

Comments
 (0)