Skip to content

Commit

Permalink
config: omit uninteresting toml_edit::Decor { .. } from test snapshots
Browse files Browse the repository at this point in the history
It was noisy, and we would see more Decor { .. } when we migrate the value
types to toml_edit.
  • Loading branch information
yuja committed Dec 8, 2024
1 parent b560e72 commit f3a44ca
Showing 1 changed file with 31 additions and 80 deletions.
111 changes: 31 additions & 80 deletions cli/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,13 @@ mod tests {

use super::*;

fn insta_settings() -> insta::Settings {
let mut settings = insta::Settings::clone_current();
// Suppress Decor { .. } which is uninteresting
settings.add_filter(r"\bDecor \{[^}]*\}", "Decor { .. }");
settings
}

#[test]
fn test_command_args() {
let mut config = StackedConfig::empty();
Expand Down Expand Up @@ -753,6 +760,8 @@ mod tests {

#[test]
fn test_resolved_config_values_single_key() {
let settings = insta_settings();
let _guard = settings.bind_to_scope();
let mut env_base_layer = ConfigLayer::empty(ConfigSource::EnvBase);
env_base_layer
.set_value("user.name", "base-user-name")
Expand All @@ -778,26 +787,14 @@ mod tests {
Key {
key: "user",
repr: None,
leaf_decor: Decor {
prefix: "default",
suffix: "default",
},
dotted_decor: Decor {
prefix: "default",
suffix: "default",
},
leaf_decor: Decor { .. },
dotted_decor: Decor { .. },
},
Key {
key: "email",
repr: None,
leaf_decor: Decor {
prefix: "default",
suffix: "default",
},
dotted_decor: Decor {
prefix: "default",
suffix: "default",
},
leaf_decor: Decor { .. },
dotted_decor: Decor { .. },
},
],
),
Expand All @@ -816,26 +813,14 @@ mod tests {
Key {
key: "user",
repr: None,
leaf_decor: Decor {
prefix: "default",
suffix: "default",
},
dotted_decor: Decor {
prefix: "default",
suffix: "default",
},
leaf_decor: Decor { .. },
dotted_decor: Decor { .. },
},
Key {
key: "name",
repr: None,
leaf_decor: Decor {
prefix: "default",
suffix: "default",
},
dotted_decor: Decor {
prefix: "default",
suffix: "default",
},
leaf_decor: Decor { .. },
dotted_decor: Decor { .. },
},
],
),
Expand All @@ -854,26 +839,14 @@ mod tests {
Key {
key: "user",
repr: None,
leaf_decor: Decor {
prefix: "default",
suffix: "default",
},
dotted_decor: Decor {
prefix: "default",
suffix: "default",
},
leaf_decor: Decor { .. },
dotted_decor: Decor { .. },
},
Key {
key: "email",
repr: None,
leaf_decor: Decor {
prefix: "default",
suffix: "default",
},
dotted_decor: Decor {
prefix: "default",
suffix: "default",
},
leaf_decor: Decor { .. },
dotted_decor: Decor { .. },
},
],
),
Expand All @@ -893,6 +866,8 @@ mod tests {

#[test]
fn test_resolved_config_values_filter_path() {
let settings = insta_settings();
let _guard = settings.bind_to_scope();
let mut user_layer = ConfigLayer::empty(ConfigSource::User);
user_layer.set_value("test-table1.foo", "user-FOO").unwrap();
user_layer.set_value("test-table2.bar", "user-BAR").unwrap();
Expand All @@ -911,26 +886,14 @@ mod tests {
Key {
key: "test-table1",
repr: None,
leaf_decor: Decor {
prefix: "default",
suffix: "default",
},
dotted_decor: Decor {
prefix: "default",
suffix: "default",
},
leaf_decor: Decor { .. },
dotted_decor: Decor { .. },
},
Key {
key: "foo",
repr: None,
leaf_decor: Decor {
prefix: "default",
suffix: "default",
},
dotted_decor: Decor {
prefix: "default",
suffix: "default",
},
leaf_decor: Decor { .. },
dotted_decor: Decor { .. },
},
],
),
Expand All @@ -949,26 +912,14 @@ mod tests {
Key {
key: "test-table1",
repr: None,
leaf_decor: Decor {
prefix: "default",
suffix: "default",
},
dotted_decor: Decor {
prefix: "default",
suffix: "default",
},
leaf_decor: Decor { .. },
dotted_decor: Decor { .. },
},
Key {
key: "bar",
repr: None,
leaf_decor: Decor {
prefix: "default",
suffix: "default",
},
dotted_decor: Decor {
prefix: "default",
suffix: "default",
},
leaf_decor: Decor { .. },
dotted_decor: Decor { .. },
},
],
),
Expand Down

0 comments on commit f3a44ca

Please sign in to comment.