idea: helper for auto cleanup of tempfile
shoenig opened this issue · comments
There is t.TempDir
which creates a tmp directory and cleans itself up at the end of the test. It would be nice if there was something similar for a single file.
var filename string
must.TmpFile(t, "content", &filename)
I still want this but not like in the example above. The problem is I never want test.*
or must.*
assertions to return a value. They should either fail the testing.T
or not. But at the same time creating a variable for the filename and passing it to be set by reference like in the example above is too messy.
So perhaps we could have a testhelp
package (name TBD) with helper functions that [may] return values.
filename := testhelp.TmpFile(t, "content")
Other package name ideas ...
testhelp
extras
utils
testutils
utiltest
helpers
utilities
testaux
moretest