-
Notifications
You must be signed in to change notification settings - Fork 416
test: make createTestDir
a general test utility
#832
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
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #832 +/- ##
==========================================
- Coverage 59.78% 59.70% -0.09%
==========================================
Files 136 136
Lines 11268 11279 +11
==========================================
- Hits 6737 6734 -3
- Misses 4102 4115 +13
- Partials 429 430 +1 ☔ View full report in Codecov by Sentry. |
internal/testutility/utility.go
Outdated
// CreateTestDir makes a temporary directory for use in testing that involves | ||
// writing and reading files from disk - make sure to call the cleanup function! | ||
func CreateTestDir(t *testing.T) (string, func()) { | ||
t.Helper() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh nice - and yeah I just realised t.TempDir
is a thing though sadly it doesn't support a prefix which I personally like to easily identify and manually clean up in the case of a failure or debugging.
Oh well, still probably best to just switch to using that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok after playing with t.TempDir
I'm not going to use it for now because we need to be able to normalize the test directory for snapshots, which is too hard with t.TempDir
right now 😞
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds reasonable. At least t.Cleanup
sounds useful in this case.
642aec7
to
8c427dc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
When doing #832 I leaned `t.Cleanup` is a thing so let's use that instead here
We've already got this duplicated in two places, and I have need for it in an upcoming PR and @robramsaynz should be using it in #797 so let's move this into
testutility