-
Notifications
You must be signed in to change notification settings - Fork 22
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
Use the idiomatic testdata folder #23
Conversation
I suspect this change will break people's existing test suites. I think we need to make the folder you put approved files in configurable as it is in other language versions like python. |
Ah yes, I had totally forgotten about that aspect. Then I will try to do as you suggest. |
The legacy behavior (i.e. no folder) will be kept as default for compatibility reasons. Use of a subfolder is made possible by the addition of a new 'UseFolder' configuration function.
I looked at Python's implementation and I was not really a fan of using a .json file as config so I tried to reuse the idea behind the UseReporter() function. So to use a subfolder you either need to specify it in each Test function or use a TestMain() |
examples_helper_test.go
Outdated
content, err := ioutil.ReadFile(approvedPath) | ||
func printFileContent(filepath string) { | ||
approvedPath := strings.Replace(filepath, ".received.", ".approved.", 1) | ||
content, err := ioutil.ReadFile(path.Join("testdata", approvedPath)) |
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.
I suspect this hardcoded "testdata" should refer instead to approvals.defaultFolder ?
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.
it is actually a bit more complicated because this file is in the approvals_test package, so it should not have access to defaultFolder. So I will revert these changes,
Thanks, this is better. Just that one comment if you could look at it? |
Thankyou! |
Solves #16