Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/assemble/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,15 @@ fn strip_frontmatter_keeps_specified_fields_case_insensitively() {
#[test]
fn map_field_finds_name_after_other_fields() {
let content = "---\ndescription: test\nname: TestAgent\n---";
let result = map_field(content, "name", |v| v.to_lowercase());
let result = map_field(content, "name", str::to_lowercase);
assert!(result.contains("name: testagent"));
assert!(result.contains("description: test"));
}

#[test]
fn map_field_handles_double_quoted_value() {
let content = "---\nname: \"SecurityArchitect\"\n---";
let result = map_field(content, "name", |v| v.to_lowercase());
let result = map_field(content, "name", str::to_lowercase);
assert!(
result.contains("name: securityarchitect"),
"quoted value should be unwrapped before mapping: {result}"
Expand All @@ -110,7 +110,7 @@ fn map_field_handles_double_quoted_value() {
#[test]
fn map_field_handles_single_quoted_value() {
let content = "---\nname: 'SecurityArchitect'\n---";
let result = map_field(content, "name", |v| v.to_lowercase());
let result = map_field(content, "name", str::to_lowercase);
assert!(
result.contains("name: securityarchitect"),
"single-quoted value should be unwrapped before mapping: {result}"
Expand All @@ -120,7 +120,7 @@ fn map_field_handles_single_quoted_value() {
#[test]
fn map_field_returns_unchanged_when_field_missing() {
let content = "---\ndescription: test\n---\nBody.";
let result = map_field(content, "name", |v| v.to_lowercase());
let result = map_field(content, "name", str::to_lowercase);
assert_eq!(result, content);
}

Expand Down
5 changes: 1 addition & 4 deletions src/yaml/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,7 @@ fn resolve_expression<'yaml>(root: &'yaml Value, expression: &str) -> Option<&'y
let mut current = root;

for segment in &segments {
match current.get(*segment) {
Some(next) => current = next,
None => return None,
}
current = current.get(*segment)?;
}

Some(current)
Expand Down
12 changes: 5 additions & 7 deletions tests/drift.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,7 @@ fn drift_both_frontmatter_and_body_difference() {
write_file(
upstream_directory.path(),
"rules/Diverged.md",
&format!(
"---\nname: Diverged\ndescription: different description\nversion: 2.0\n---\n\nUpstream body content.\n"
),
"---\nname: Diverged\ndescription: different description\nversion: 2.0\n---\n\nUpstream body content.\n",
);

let output = forge()
Expand Down Expand Up @@ -745,12 +743,12 @@ fn ignore_both_frontmatter_and_body() {
write_file(
module_directory.path(),
"rules/TestRule.md",
&format!("---\nname: TestRule\nproject: local\n---\n\nLocal body.\n"),
"---\nname: TestRule\nproject: local\n---\n\nLocal body.\n",
);
write_file(
upstream_directory.path(),
"rules/TestRule.md",
&format!("---\nname: TestRule\nproject: upstream\n---\n\nUpstream body.\n"),
"---\nname: TestRule\nproject: upstream\n---\n\nUpstream body.\n",
);

let output = forge()
Expand Down Expand Up @@ -782,12 +780,12 @@ fn ignore_body_on_both_drift_keeps_frontmatter() {
write_file(
module_directory.path(),
"rules/TestRule.md",
&format!("---\nname: TestRule\nversion: 2.0\n---\n\nLocal body.\n"),
"---\nname: TestRule\nversion: 2.0\n---\n\nLocal body.\n",
);
write_file(
upstream_directory.path(),
"rules/TestRule.md",
&format!("---\nname: TestRule\nversion: 1.0\n---\n\nUpstream body.\n"),
"---\nname: TestRule\nversion: 1.0\n---\n\nUpstream body.\n",
);

let output = forge()
Expand Down
3 changes: 1 addition & 2 deletions tests/prune.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,7 @@ fn run_two_pass_prune_for_provider(provider: &str) {
assert_eq!(
trash_entries.len(),
1,
"{provider}: exactly one timestamped trash entry expected, found {:?}",
trash_entries
"{provider}: exactly one timestamped trash entry expected, found {trash_entries:?}"
);
let trash_dir = &trash_entries[0];
assert!(
Expand Down