Skip to content

Commit

Permalink
Merge pull request #23 from bayashi/add-direct-message-method
Browse files Browse the repository at this point in the history
Add `Message` method to directly set label and message
  • Loading branch information
bayashi committed Jan 8, 2024
2 parents 56e6c5c + 653f666 commit cd3e925
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions witness.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,12 @@ func (w *Witness) Expect(v any) *Witness {
return w
}

func baseReprot(reason string) *report.Failure {
return report.NewFailure().
Trace(strings.Join(trace.Info(), "\n\t")).
Reason(reason)
// Set additional messages to show
func Message(label string, msg string) *Witness {
w := &Witness{}
w.messages = append(w.messages, map[string]string{label: msg})

return w
}

// Set additional messages to show
Expand All @@ -142,6 +144,12 @@ func (w *Witness) Message(label string, msg string) *Witness {
return w
}

func baseReprot(reason string) *report.Failure {
return report.NewFailure().
Trace(strings.Join(trace.Info(), "\n\t")).
Reason(reason)
}

var funcFail = func(t *testing.T, r *report.Failure) {
t.Helper()
t.Fail()
Expand Down

0 comments on commit cd3e925

Please sign in to comment.