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

Golden tests for JSON instances #1486

Merged
merged 20 commits into from
May 10, 2021
Merged

Golden tests for JSON instances #1486

merged 20 commits into from
May 10, 2021

Conversation

pcapriotti
Copy link
Contributor

@pcapriotti pcapriotti commented May 4, 2021

This introduces some golden tests for JSON instances. The way this works is that when the test does not find JSON files to compare against, it fails, but it also generates them. One is supposed to add the files to git, and rerun the tests (which will now mostly likely pass). If in the future the JSON instance changes, the test will hopefully catch it.

The way the tests are generated is a bit hacky and hard to reproduce, but hopefully it shouldn't be done too often. Basically, the wire-server code is patched to add some ad-hoc Show instances. Then the Arbitrary instances are used to generate random objects, which are then printed and end up in the Golden.Generated module as Haskell code. Some of this code is fixed by a sed script after the fact.

So to regenerate Golden.Generated one can do the following:

  • apply the patch(es) in libs/wire-api/test/golden/ with git am
  • from libs/wire-api, run the gentests.sh script
  • undo the patch (but keep the generated code)

TODO

  • Prune unused imports from generated files
  • Group tests by type

@pcapriotti pcapriotti force-pushed the pcapriotti/golden-tests branch 4 times, most recently from c68fe94 to 42d0d72 Compare May 6, 2021 08:53
@pcapriotti pcapriotti marked this pull request as ready for review May 6, 2021 08:54
@pcapriotti pcapriotti changed the title [WIP] Golden tests for JSON instances [skip ci] Golden tests for JSON instances May 10, 2021
Copy link
Member

@akshaymankar akshaymankar left a comment

Choose a reason for hiding this comment

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

Looks good, but let's add license headers to all the generated haskell.

@pcapriotti pcapriotti merged commit ee2f787 into develop May 10, 2021
@pcapriotti pcapriotti deleted the pcapriotti/golden-tests branch May 10, 2021 11:49
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.

2 participants