You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Have File assertions, like the currently existing JSON assertions
This is the "hacky" solution as this would be essentially calling the existing assertions, with the second parameter given after reading a file, like:
funcShouldJSONFileEqual(actualinterface{}, expectedFileinterface{}) error {
expected, err:=// get bytes from file and dumpreturnShouldJSONEqual(actual, expected) error
}
Add a variable helper that reads from a file
This is the solution I like the most, as it would not add more similar assertions and it is a bit more "elegant" to look at when reading the test file.
If for example we have a file called ./expected.json
This implementation solutions of course would not be limited to JSON, this is the most familiar example I came up with :)
Let me know what you think about this and if it is OK for you to continue with either implementation, or some other one, I can go ahead and start working on it.
The text was updated successfully, but these errors were encountered:
I noticed that the existing assertions work only with given values or variables, but not with files.
In my day job we would like to have the option to run assertions against golden files (files which contain the expected output of some operation).
For example, if we want to compare some JSON output, currently we do:
I have two proposed solutions for this problem:
File
assertions, like the currently existing JSON assertionsThis is the "hacky" solution as this would be essentially calling the existing assertions, with the second parameter given after reading a file, like:
This is the solution I like the most, as it would not add more similar assertions and it is a bit more "elegant" to look at when reading the test file.
If for example we have a file called
./expected.json
We could test the result against it in this way:
This implementation solutions of course would not be limited to JSON, this is the most familiar example I came up with :)
Let me know what you think about this and if it is OK for you to continue with either implementation, or some other one, I can go ahead and start working on it.
The text was updated successfully, but these errors were encountered: