Skip to content

Commit

Permalink
Mark VerifyNone as a test Helper
Browse files Browse the repository at this point in the history
  • Loading branch information
tallclair committed Aug 29, 2022
1 parent 4e045fd commit 3fde09c
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions leaks.go
Expand Up @@ -69,12 +69,21 @@ func Find(options ...Option) error {
return fmt.Errorf("found unexpected goroutines:\n%s", stacks)
}

type testHelper interface {
Helper()
}

// VerifyNone marks the given TestingT as failed if any extra goroutines are
// found by Find. This is a helper method to make it easier to integrate in
// tests by doing:
//
// defer VerifyNone(t)
func VerifyNone(t TestingT, options ...Option) {
if h, ok := t.(testHelper); ok {
// Mark this function as a test helper, if available.
h.Helper()
}

if err := Find(options...); err != nil {
t.Error(err)
}
Expand Down

0 comments on commit 3fde09c

Please sign in to comment.