Skip to content

Commit

Permalink
feat: enhance test naming by making it a format string (#20)
Browse files Browse the repository at this point in the history
This change updates the "Ensure(string)" method to accept a format
string and a varargs argument, allowing the user to provide a
parameterized description of the test.
  • Loading branch information
arikkfir committed Jun 10, 2024
1 parent 345aeae commit ac8fdf1
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions asserter.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func With(t T) VerifierAndEnsurer {

type VerifierAndEnsurer interface {
Verifier
Ensure(string) Verifier
Ensure(string, ...any) Verifier
}

type Verifier interface {
Expand All @@ -34,9 +34,9 @@ type verifier struct {
}

//go:noinline
func (v *verifier) Ensure(description string) Verifier {
func (v *verifier) Ensure(format string, args ...any) Verifier {
GetHelper(v.t).Helper()
v.desc = description
v.desc = fmt.Sprintf(format, args...)
return v
}

Expand Down

0 comments on commit ac8fdf1

Please sign in to comment.