-
-
Notifications
You must be signed in to change notification settings - Fork 127
Description
I'm finding the crate is getting increasingly complicated, to the extent that as the second contributor (albeit far behind @mitsuhiko...) I'm sometimes scratching my head in how things work. Features such as #489 are great but will continue to make the main path more complicated.
Potentially some unnecessary complication comes from how differently inline & file snapshots are handled:
- Pending inline snapshots write to
.pending-snap
files, "pending" file snapshots write to.snap.new
files - Pending inline snapshots contain both the old & new value; pending file snapshots only contain the new value
- Pending inline snapshots have a single file per rust file in which each snapshot gets a separate json entry, pending file snapshots have a file per snapshot
- Pending inline snapshots track a run-id
Could we instead use .snap.new
files for both file and pending snapshots, with a marker in their metadata indicating which is which? We'd read the old value from the rust file itself, wouldn't need to track run-id, and so collapse a lot of code in our main path. (We'd need to think about how line numbers change as code is updated, maybe other things I haven't thought of). As well as making the crate simpler, we also make its explanation simpler — when writing docs we often have to give footnotes like this:
Lines 171 to 172 in 58daea1
//! value into a draft file (note that inline snapshots use `.pending-snap` | |
//! files rather than `.snap.new` files). Running `cargo insta review` will |
We'd need to handle both for a while, and so somewhat dependent on a mechanism such as #509 to ensure we don't have to handle both forever