-
-
Notifications
You must be signed in to change notification settings - Fork 103
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
API to read snapshots #353
Comments
Another approach here would be an API for writing & managing files that weren't So in the case above, we could write files like https://github.com/PRQL/prql/blob/2ecdfaac4796e12772afd0394268fdd9f366ab02/book/tests/prql/transforms/from_text-0.prql, and use insta rather than code like this: https://github.com/PRQL/prql/blob/2ecdfaac4796e12772afd0394268fdd9f366ab02/book/tests/snapshot.rs#L123-L159. |
I realize there's a wall of text above, and my thinking has coalesced, so to summarize on the APi I'm thinking of:
|
+1 for something like this. Use case: We're using async-graphql, which is a code-first graphql library. But we need to generate the SDL schema for our GraphQL API so other languages/libraries can interact with our API. I reached for Insta thinking I could just make an insta test and pass it my
|
I mean you can load snapshots even today with the |
In another thread I show an example of testing library implementation with support for snapshots. |
I dumped some ideas over there for how this could work if the snapshot macro were to be changed: #456 (comment) |
One simple incremental approach would be to have an
It's a bit less orthogonal than other approaches — generally the macro type concerns the format of the snapshot rather than its type. But it would be useful. Another approach would be |
For future travelers — #610 does some of this, since it can write an arbitrary value to an arbitrary file. (it doesn't allow literally reading snapshots though, still need some mapping to the file path) |
Edit: to avoid reading this wall of text, see this comment for a summary
Below is the original comment
We have a process in PRQL to extract, compile, and test the examples in our book / docs. Currently we're extracting each PRQL example, making our own snapshot of the PRQL, and then running insta snapshots on the result of compiling that PRQL to SQL.
I wonder whether this is a common case, and we could replace "making our own snapshots of it" with "make an insta snapshot and then read it". For that, we'd need some sort of API where we could do something like
read_snapshots!(prefix) -> [(id, snapshot_text)]
or similarFull details:
Another use case for something like this would be testing a pipeline without having to start from the beginning. For example, to test our compilation, we could have a snapshot of each stage of the compiler, and be able to test the final step by reading a snapshot of the result in the middle, running the final stage, and asserting it matches a snapshotted final result. Currently with insta we can snapshot each stage, but it requires starting from the beginning.
This is an idea I've been brewing on today when writing some of this code, so possibly it's not complete / there is a simpler way to achieve the goal / it's actually fairly rare to need to start with an intermediate result.
The text was updated successfully, but these errors were encountered: