Skip to content

Commit

Permalink
tests: run insta --force-update-snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobhellermann committed Feb 9, 2025
1 parent 07c63ed commit d528719
Show file tree
Hide file tree
Showing 84 changed files with 4,702 additions and 5,730 deletions.
30 changes: 14 additions & 16 deletions cli/src/formatter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -857,7 +857,7 @@ mod tests {
formatter.pop_label().unwrap();
write!(formatter, " after ").unwrap();
drop(formatter);
insta::assert_snapshot!(String::from_utf8(output).unwrap(), @" before [38;5;2m inside [39m after ");
insta::assert_snapshot!(String::from_utf8(output).unwrap(), @" before [38;5;2m inside [39m after");
}

#[test]
Expand Down Expand Up @@ -907,15 +907,15 @@ mod tests {
formatter.pop_label().unwrap();
writeln!(formatter).unwrap();
drop(formatter);
insta::assert_snapshot!(String::from_utf8(output).unwrap(), @r###"
insta::assert_snapshot!(String::from_utf8(output).unwrap(), @r"
 fg only 
 bg only 
 bold only 
 italic only 
 underlined only 
 single rule 
 two rules 
"###);
");
}

#[test]
Expand Down Expand Up @@ -1005,7 +1005,7 @@ mod tests {
write!(formatter, " after outer ").unwrap();
drop(formatter);
insta::assert_snapshot!(String::from_utf8(output).unwrap(),
@" before outer [38;5;4m before inner [38;5;2m inside inner [38;5;4m after inner [39m after outer ");
@" before outer [38;5;4m before inner [38;5;2m inside inner [38;5;4m after inner [39m after outer");
}

#[test]
Expand All @@ -1027,7 +1027,7 @@ mod tests {
formatter.pop_label().unwrap();
drop(formatter);
insta::assert_snapshot!(String::from_utf8(output).unwrap(),
@" not colored [38;5;2m colored [39m not colored ");
@" not colored [38;5;2m colored [39m not colored");
}

#[test]
Expand Down Expand Up @@ -1106,10 +1106,10 @@ mod tests {
write!(formatter, " and back.").unwrap();
drop(formatter);
insta::assert_snapshot!(String::from_utf8(output).unwrap(),
@r###"
@r"
Blue on yellow,  default fg,  and back.
Blue on yellow,  default bg,  and back.
"###);
");
}

#[test]
Expand Down Expand Up @@ -1149,7 +1149,7 @@ mod tests {
formatter.pop_label().unwrap();
formatter.pop_label().unwrap();
drop(formatter);
insta::assert_snapshot!(String::from_utf8(output).unwrap(), @" hello ");
insta::assert_snapshot!(String::from_utf8(output).unwrap(), @" hello");
}

#[test]
Expand Down Expand Up @@ -1241,9 +1241,7 @@ mod tests {
write!(writer, "Message").unwrap();
writeln!(writer, " continues").unwrap();
drop(formatter);
insta::assert_snapshot!(String::from_utf8(output).unwrap(), @r###"
Heading: Message continues
"###);
insta::assert_snapshot!(String::from_utf8(output).unwrap(), @"Heading: Message continues");
}

#[test]
Expand All @@ -1259,7 +1257,7 @@ mod tests {
write!(writer, "").unwrap();
write!(writer, "").unwrap();
drop(formatter);
insta::assert_snapshot!(String::from_utf8(output).unwrap(), @"Heading: ");
insta::assert_snapshot!(String::from_utf8(output).unwrap(), @"Heading:");
}

#[test]
Expand All @@ -1274,7 +1272,7 @@ mod tests {

insta::assert_snapshot!(
str::from_utf8(recorder.data()).unwrap(),
@" outer1 inner1 inner2 outer2 ");
@" outer1 inner1 inner2 outer2");

// Replayed output should be labeled.
let config = config_from_string(r#" colors.inner = "red" "#);
Expand All @@ -1284,7 +1282,7 @@ mod tests {
drop(formatter);
insta::assert_snapshot!(
String::from_utf8(output).unwrap(),
@" outer1 [38;5;1m inner1 inner2 [39m outer2 ");
@" outer1 [38;5;1m inner1 inner2 [39m outer2");

// Replayed output should be split at push/pop_label() call.
let mut output: Vec<u8> = vec![];
Expand Down Expand Up @@ -1319,7 +1317,7 @@ mod tests {
recorder.replay(&mut formatter).unwrap();
drop(formatter);
insta::assert_snapshot!(
String::from_utf8(output).unwrap(), @" outer1 [38;5;1m inner1 inner2 [39m outer2 ");
String::from_utf8(output).unwrap(), @" outer1 [38;5;1m inner1 inner2 [39m outer2");

let mut output: Vec<u8> = vec![];
let mut formatter = ColorFormatter::for_config(&mut output, &config, false).unwrap();
Expand All @@ -1333,6 +1331,6 @@ mod tests {
.unwrap();
drop(formatter);
insta::assert_snapshot!(
String::from_utf8(output).unwrap(), @" outer1 [38;5;1m inner1 inner2 [39m outer2 ");
String::from_utf8(output).unwrap(), @" outer1 [38;5;1m inner1 inner2 [39m outer2");
}
}
2 changes: 1 addition & 1 deletion cli/src/git_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@ mod tests {
};
// First output is after the initial delay
assert_snapshot!(update(crate::progress::INITIAL_DELAY - Duration::from_millis(1), 0.1), @"");
assert_snapshot!(update(Duration::from_millis(1), 0.10), @"[?25l\r 10% [█▊ ][K");
assert_snapshot!(update(Duration::from_millis(1), 0.10), @"\u{1b}[?25l\r 10% [█▊ ]\u{1b}[K");
// No updates for the next 30 milliseconds
assert_snapshot!(update(Duration::from_millis(10), 0.11), @"");
assert_snapshot!(update(Duration::from_millis(10), 0.12), @"");
Expand Down
20 changes: 10 additions & 10 deletions cli/src/merge_tools/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@ mod tests {
ConflictMarkerStyle::Diff,
)
.unwrap();
insta::assert_debug_snapshot!(files, @r###"
insta::assert_debug_snapshot!(files, @r#"
[
File {
old_path: None,
Expand Down Expand Up @@ -821,7 +821,7 @@ mod tests {
],
},
]
"###);
"#);

let no_changes_tree_id = apply_diff_builtin(
store,
Expand Down Expand Up @@ -870,7 +870,7 @@ mod tests {
ConflictMarkerStyle::Diff,
)
.unwrap();
insta::assert_debug_snapshot!(files, @r###"
insta::assert_debug_snapshot!(files, @r#"
[
File {
old_path: None,
Expand All @@ -893,7 +893,7 @@ mod tests {
],
},
]
"###);
"#);
let no_changes_tree_id = apply_diff_builtin(
store,
&left_tree,
Expand Down Expand Up @@ -941,7 +941,7 @@ mod tests {
ConflictMarkerStyle::Diff,
)
.unwrap();
insta::assert_debug_snapshot!(files, @r###"
insta::assert_debug_snapshot!(files, @r#"
[
File {
old_path: None,
Expand All @@ -964,7 +964,7 @@ mod tests {
],
},
]
"###);
"#);
let no_changes_tree_id = apply_diff_builtin(
store,
&left_tree,
Expand Down Expand Up @@ -1013,7 +1013,7 @@ mod tests {
ConflictMarkerStyle::Diff,
)
.unwrap();
insta::assert_debug_snapshot!(files, @r###"
insta::assert_debug_snapshot!(files, @r#"
[
File {
old_path: None,
Expand All @@ -1036,7 +1036,7 @@ mod tests {
],
},
]
"###);
"#);
let no_changes_tree_id = apply_diff_builtin(
store,
&left_tree,
Expand Down Expand Up @@ -1103,7 +1103,7 @@ mod tests {
.unwrap();
let merge_result = files::merge(&content);
let sections = make_merge_sections(merge_result).unwrap();
insta::assert_debug_snapshot!(sections, @r###"
insta::assert_debug_snapshot!(sections, @r#"
[
Changed {
lines: [
Expand Down Expand Up @@ -1151,6 +1151,6 @@ mod tests {
],
},
]
"###);
"#);
}
}
12 changes: 6 additions & 6 deletions cli/src/merge_tools/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -703,11 +703,11 @@ mod tests {
insta::assert_debug_snapshot!(get(":builtin", "").unwrap(), @"Builtin");

// Just program name
insta::assert_debug_snapshot!(get("my diff", "").unwrap_err(), @r###"
insta::assert_debug_snapshot!(get("my diff", "").unwrap_err(), @r#"
MergeArgsNotConfigured {
tool_name: "my diff",
}
"###);
"#);

// Pick from merge-tools
insta::assert_debug_snapshot!(get(
Expand Down Expand Up @@ -763,11 +763,11 @@ mod tests {
insta::assert_debug_snapshot!(get("").unwrap(), @"Builtin");

// Just program name
insta::assert_debug_snapshot!(get(r#"ui.merge-editor = "my-merge""#).unwrap_err(), @r###"
insta::assert_debug_snapshot!(get(r#"ui.merge-editor = "my-merge""#).unwrap_err(), @r#"
MergeArgsNotConfigured {
tool_name: "my-merge",
}
"###);
"#);

// String args
insta::assert_debug_snapshot!(
Expand Down Expand Up @@ -871,11 +871,11 @@ mod tests {

// List args should never be a merge-tools key
insta::assert_debug_snapshot!(
get(r#"ui.merge-editor = ["meld"]"#).unwrap_err(), @r###"
get(r#"ui.merge-editor = ["meld"]"#).unwrap_err(), @r#"
MergeArgsNotConfigured {
tool_name: "meld",
}
"###);
"#);

// Invalid type
assert!(get(r#"ui.merge-editor.k = 0"#).is_err());
Expand Down
Loading

0 comments on commit d528719

Please sign in to comment.