Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mark more internal funcs as helpers #161

Merged
merged 1 commit into from
Jun 15, 2024
Merged

Conversation

gulducat
Copy link
Contributor

hi!

given this test_test.go:

   1 package main
   2
   3 import (
   4     "testing"
   5
   6     "github.com/shoenig/test"
   7     "github.com/shoenig/test/must"
   8 )
   9
  10 func TestHelperStack(t *testing.T) {
  11     failSadly(t)
  12 }
  13
  14 func failSadly(t *testing.T) {
  15     t.Helper()
  16     test.NotNil(t, nil)
  17     must.NotNil(t, nil)
  18 }

before this change, error stack shows assert.go from this lib:

$ go test .
--- FAIL: TestHelperStack (0.00s)
    assert.go:14:
        test_test.go:16: expected to not be nil; is nil
    assert.go:14:
        test_test.go:17: expected to not be nil; is nil

after, shows my test file(s) with the context relevant to me and my terrible mistakes:

$ go test .
--- FAIL: TestHelperStack (0.00s)
    test_test.go:11:
        test_test.go:16: expected to not be nil; is nil
    test_test.go:11:
        test_test.go:17: expected to not be nil; is nil

@ccoVeille
Copy link
Contributor

That's indeed t.Helper() purpose 👍

Copy link
Owner

@shoenig shoenig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks @gulducat!

@shoenig shoenig merged commit f903659 into shoenig:main Jun 15, 2024
6 checks passed
@gulducat gulducat deleted the more-helper branch June 17, 2024 13:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants