mirror of
https://github.com/martinvonz/jj.git
synced 2025-01-12 23:23:20 +00:00
formatter: in tests, use IndexMap to preserve definition order of colors
This commit is contained in:
parent
1d58bdc8eb
commit
1c7634fcf0
3 changed files with 21 additions and 21 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -1849,6 +1849,7 @@ checksum = "62f822373a4fe84d4bb149bf54e584a7f4abec90e072ed49cda0edea5b95471f"
|
|||
dependencies = [
|
||||
"equivalent",
|
||||
"hashbrown 0.15.2",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
|
@ -67,7 +67,7 @@ glob = "0.3.1"
|
|||
hashbrown = { version = "0.15.2", default-features = false, features = ["inline-more"] }
|
||||
hex = "0.4.3"
|
||||
ignore = "0.4.23"
|
||||
indexmap = "2.7.0"
|
||||
indexmap = { version = "2.7.0", features = ["serde"] }
|
||||
indoc = "2.0.4"
|
||||
insta = { version = "1.41.1", features = ["filters"] }
|
||||
itertools = "0.13.0"
|
||||
|
|
|
@ -709,6 +709,7 @@ mod tests {
|
|||
use std::error::Error as _;
|
||||
use std::str;
|
||||
|
||||
use indexmap::IndexMap;
|
||||
use indoc::indoc;
|
||||
use jj_lib::config::ConfigLayer;
|
||||
use jj_lib::config::ConfigSource;
|
||||
|
@ -774,11 +775,10 @@ mod tests {
|
|||
bright-cyan = 'bright cyan'
|
||||
bright-white = 'bright white'
|
||||
"});
|
||||
// TODO: migrate off config::Config and switch to IndexMap
|
||||
let colors: HashMap<String, String> = config.get("colors").unwrap();
|
||||
let colors: IndexMap<String, String> = config.get("colors").unwrap();
|
||||
let mut output: Vec<u8> = vec![];
|
||||
let mut formatter = ColorFormatter::for_config(&mut output, &config, false).unwrap();
|
||||
for (label, color) in colors.iter().sorted() {
|
||||
for (label, color) in &colors {
|
||||
formatter.push_label(label).unwrap();
|
||||
write!(formatter, " {color} ").unwrap();
|
||||
formatter.pop_label().unwrap();
|
||||
|
@ -787,21 +787,21 @@ mod tests {
|
|||
drop(formatter);
|
||||
insta::assert_snapshot!(String::from_utf8(output).unwrap(), @r"
|
||||
[38;5;0m black [39m
|
||||
[38;5;4m blue [39m
|
||||
[38;5;8m bright black [39m
|
||||
[38;5;12m bright blue [39m
|
||||
[38;5;14m bright cyan [39m
|
||||
[38;5;10m bright green [39m
|
||||
[38;5;13m bright magenta [39m
|
||||
[38;5;9m bright red [39m
|
||||
[38;5;15m bright white [39m
|
||||
[38;5;11m bright yellow [39m
|
||||
[38;5;6m cyan [39m
|
||||
[38;5;2m green [39m
|
||||
[38;5;5m magenta [39m
|
||||
[38;5;1m red [39m
|
||||
[38;5;7m white [39m
|
||||
[38;5;2m green [39m
|
||||
[38;5;3m yellow [39m
|
||||
[38;5;4m blue [39m
|
||||
[38;5;5m magenta [39m
|
||||
[38;5;6m cyan [39m
|
||||
[38;5;7m white [39m
|
||||
[38;5;8m bright black [39m
|
||||
[38;5;9m bright red [39m
|
||||
[38;5;10m bright green [39m
|
||||
[38;5;11m bright yellow [39m
|
||||
[38;5;12m bright blue [39m
|
||||
[38;5;13m bright magenta [39m
|
||||
[38;5;14m bright cyan [39m
|
||||
[38;5;15m bright white [39m
|
||||
");
|
||||
}
|
||||
|
||||
|
@ -814,11 +814,10 @@ mod tests {
|
|||
white = '#ffffff'
|
||||
pastel-blue = '#AFE0D9'
|
||||
"});
|
||||
// TODO: migrate off config::Config and switch to IndexMap
|
||||
let colors: HashMap<String, String> = config.get("colors").unwrap();
|
||||
let colors: IndexMap<String, String> = config.get("colors").unwrap();
|
||||
let mut output: Vec<u8> = vec![];
|
||||
let mut formatter = ColorFormatter::for_config(&mut output, &config, false).unwrap();
|
||||
for label in colors.keys().sorted() {
|
||||
for label in colors.keys() {
|
||||
formatter.push_label(&label.replace(' ', "-")).unwrap();
|
||||
write!(formatter, " {label} ").unwrap();
|
||||
formatter.pop_label().unwrap();
|
||||
|
@ -827,8 +826,8 @@ mod tests {
|
|||
drop(formatter);
|
||||
insta::assert_snapshot!(String::from_utf8(output).unwrap(), @r"
|
||||
[38;2;0;0;0m black [39m
|
||||
[38;2;175;224;217m pastel-blue [39m
|
||||
[38;2;255;255;255m white [39m
|
||||
[38;2;175;224;217m pastel-blue [39m
|
||||
");
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue