Skip to content

Commit

Permalink
Also test cargo insta reject
Browse files Browse the repository at this point in the history
  • Loading branch information
max-sixty committed Oct 12, 2024
1 parent 683bf17 commit e3aa512
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions cargo-insta/tests/functional/delete_pending.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,54 @@ fn test_file_snapshot() {
+ src/snapshots/test_combined_snapshot_deletion__file_snapshot.snap.new
");

// Run `cargo insta reject` to delete pending snapshots
assert!(test_project
.insta_cmd()
.args(["reject"])
.output()
.unwrap()
.status
.success());

// Pending snapshots should be deleted
assert_snapshot!(test_project.file_tree_diff(), @r"
--- Original file tree
+++ Updated file tree
@@ -1,4 +1,7 @@
+ Cargo.lock
Cargo.toml
src
src/lib.rs
+ src/snapshots
+ src/snapshots/test_combined_snapshot_deletion__file_snapshot.snap
");

// Run the tests again to create pending snapshots
assert!(!test_project
.insta_cmd()
.args(["test"])
.output()
.unwrap()
.status
.success());

// They should be back...
assert_snapshot!(test_project.file_tree_diff(), @r"
--- Original file tree
+++ Updated file tree
@@ -1,4 +1,9 @@
+ Cargo.lock
Cargo.toml
src
+ src/.lib.rs.pending-snap
src/lib.rs
+ src/snapshots
+ src/snapshots/test_combined_snapshot_deletion__file_snapshot.snap
+ src/snapshots/test_combined_snapshot_deletion__file_snapshot.snap.new
");

// Modify the test back so they pass
test_project.update_file(
"src/lib.rs",
Expand Down

0 comments on commit e3aa512

Please sign in to comment.