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.19.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.19.1
Choose a head ref
  • 4 commits
  • 7 files changed
  • 1 contributor

Commits on Aug 30, 2022

  1. Copy the full SHA
    8ed8c29 View commit details

Commits on Aug 31, 2022

  1. Copy the full SHA
    89ef139 View commit details
  2. Changelog entry

    mitsuhiko committed Aug 31, 2022
    Copy the full SHA
    c6202bb View commit details
  3. 1.19.1

    mitsuhiko committed Aug 31, 2022
    Copy the full SHA
    95d1e88 View commit details
Showing with 31 additions and 14 deletions.
  1. +1 −0 .gitignore
  2. +4 −0 CHANGELOG.md
  3. +1 −1 Cargo.toml
  4. +2 −2 cargo-insta/Cargo.lock
  5. +2 −2 cargo-insta/Cargo.toml
  6. +21 −1 src/content/json.rs
  7. +0 −8 src/snapshots/doctest_runtime_rs__unnamed_doctest.snap
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
target
**/*.rs.bk
/Cargo.lock
.vscode/*.log
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -2,6 +2,10 @@

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

## 1.19.1

- Added support for numeric keys in JSON which regressed in 0.18.0. (#281)

## 1.19.0

- Removed `backtrace` feature.
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.19.0"
version = "1.19.1"
license = "Apache-2.0"
authors = ["Armin Ronacher <armin.ronacher@active-4.com>"]
description = "A snapshot testing library for Rust"
4 changes: 2 additions & 2 deletions cargo-insta/Cargo.lock

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

4 changes: 2 additions & 2 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.19.0"
version = "1.19.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,7 +12,7 @@ edition = "2018"
readme = "README.md"

[dependencies]
insta = { version = "=1.19.0", path = "..", features = ["json", "yaml", "redactions"] }
insta = { version = "=1.19.1", path = "..", features = ["json", "yaml", "redactions"] }
console = "0.15.1"
structopt = "0.3.20"
serde = { version = "1.0.117", features = ["derive"] }
22 changes: 21 additions & 1 deletion src/content/json.rs
Original file line number Diff line number Diff line change
@@ -157,8 +157,13 @@ impl Serializer {
self.start_container('{');
for (idx, (key, value)) in map.iter().enumerate() {
self.write_comma(idx == 0);
if let Content::String(ref s) = key {
let real_key = key.resolve_inner();
if let Content::String(ref s) = real_key {
self.write_escaped_str(s);
} else if let Some(num) = real_key.as_i64() {
self.write_escaped_str(&num.to_string());
} else if let Some(num) = real_key.as_i128() {
self.write_escaped_str(&num.to_string());
} else {
panic!("cannot serialize maps without string keys to JSON");
}
@@ -322,6 +327,21 @@ fn test_to_string_pretty() {
"###);
}

#[test]
fn test_to_string_num_keys() {
let content = Content::Map(vec![
(Content::from(42u32), Content::from(true)),
(Content::from(-23i32), Content::from(false)),
]);
let json = to_string_pretty(&content);
crate::assert_snapshot!(&json, @r###"
{
"42": true,
"-23": false
}
"###);
}

#[test]
fn test_to_string_pretty_complex() {
let content = Content::Map(vec![
8 changes: 0 additions & 8 deletions src/snapshots/doctest_runtime_rs__unnamed_doctest.snap

This file was deleted.