Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: mitsuhiko/insta
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 1.14.0
Choose a base ref
...
head repository: mitsuhiko/insta
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 1.14.1
Choose a head ref
  • 4 commits
  • 5 files changed
  • 3 contributors

Commits on Apr 27, 2022

  1. Use inline block format also for strings of form "foo\n" (#225)

    This changes the formatting for strings with a trailing newline to block format.
    martinvonz authored Apr 27, 2022

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    56504f1 View commit details
  2. Added changelog entry for #225

    mitsuhiko committed Apr 27, 2022
    Copy the full SHA
    b9d99e8 View commit details

Commits on May 31, 2022

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    71a907b View commit details
  2. 1.14.1

    mitsuhiko committed May 31, 2022
    Copy the full SHA
    beaee73 View commit details
Showing with 25 additions and 10 deletions.
  1. +5 −0 CHANGELOG.md
  2. +1 −1 Cargo.toml
  3. +4 −4 cargo-insta/Cargo.lock
  4. +3 −3 cargo-insta/Cargo.toml
  5. +12 −2 src/snapshot.rs
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -2,6 +2,11 @@

All notable changes to insta and cargo-insta are documented here.

## 1.14.1

- Update uuid crate to 1.0.0. (#228)
- Use inline block format also for strings of form `"foo\n"`. (#225)

## 1.14.0

- Fixed a bug that caused insta to panic if inline snapshot assertions
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "insta"
version = "1.14.0"
version = "1.14.1"
license = "Apache-2.0"
authors = ["Armin Ronacher <armin.ronacher@active-4.com>"]
description = "A snapshot testing library for Rust"
8 changes: 4 additions & 4 deletions cargo-insta/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions cargo-insta/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cargo-insta"
version = "1.14.0"
version = "1.14.1"
license = "Apache-2.0"
authors = ["Armin Ronacher <armin.ronacher@active-4.com>"]
description = "A review tool for the insta snapshot testing library for Rust"
@@ -12,12 +12,12 @@ edition = "2018"
readme = "README.md"

[dependencies]
insta = { version = "1.14.0", path = "..", features = ["redactions"] }
insta = { version = "1.14.1", path = "..", features = ["redactions"] }
console = "0.15.0"
structopt = "0.3.20"
serde = { version = "1.0.117", features = ["derive"] }
serde_json = "1.0.59"
proc-macro2 = { version = "1.0.24", features = ["span-locations"] }
syn = { version = "1.0.50", features = ["full", "visit", "extra-traits"] }
ignore = "0.4.17"
uuid = { version = "0.8.1", features = ["v4"] }
uuid = { version = "1.0.0", features = ["v4"] }
14 changes: 12 additions & 2 deletions src/snapshot.rs
Original file line number Diff line number Diff line change
@@ -317,12 +317,12 @@ impl SnapshotContents {
pub fn to_inline(&self, indentation: usize) -> String {
let contents = &self.0;
let mut out = String::new();
let is_escape = contents.lines().count() > 1 || contents.contains(&['\\', '"'][..]);
let is_escape = contents.contains(&['\n', '\\', '"'][..]);

out.push_str(if is_escape { "r###\"" } else { "\"" });
// if we have more than one line we want to change into the block
// representation mode
if contents.lines().count() > 1 {
if contents.contains('\n') {
out.extend(
contents
.lines()
@@ -512,6 +512,16 @@ b"[1..];
\"###"
);

let t = &"
ab
"[1..];
assert_eq!(
SnapshotContents(t.to_string()).to_inline(0),
"r###\"
ab
\"###"
);

let t = "ab";
assert_eq!(SnapshotContents(t.to_string()).to_inline(0), r##""ab""##);
}