Skip to content

Commit

Permalink
chore: Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
dustinblackman committed Nov 24, 2024
1 parent c63d362 commit af17a60
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/cargo_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ fn update_aliases_toml(
doc["alias"] = table();
}

// If the TOML structure is not as and we panic because of that, that makes for poor user
// experience, so try to report errors for everything that could go wrong.
// If the TOML structure is not as and we panic because of that, that makes for
// poor user experience, so try to report errors for everything that could
// go wrong.
let aliases = doc["alias"]
.as_table_mut()
.context("alias key should be a table")?;
Expand All @@ -51,9 +52,10 @@ fn update_aliases_toml(
let [name] = key.as_slice() else {
bail!("unexpected nested table: {key:?}")
};
// The value can be either a single string (implicitly split on spaces) or an array of
// strings. We always create an array, but a user might use a single string for other
// aliases, so we have to at least not crash on such values.
// The value can be either a single string (implicitly split on spaces) or an
// array of strings. We always create an array, but a user might use a
// single string for other aliases, so we have to at least not crash on
// such values.
if let Value::Array(parts) = value {
let first_part = parts
.get(0)
Expand Down Expand Up @@ -121,16 +123,16 @@ xtask = "run --package xtask --"
#[test]
fn doesnt_panic_on_empty_array() {
let result = update_aliases_toml("alias.mistake = []", Vec::new());
// Currently an error, could be skipped instead, in that case the Ok(..) result should be
// tested a bit.
// Currently an error, could be skipped instead, in that case the Ok(..) result
// should be tested a bit.
assert!(result.is_err());
}

#[test]
fn doesnt_panic_on_nested_keys() {
let result = update_aliases_toml("alias.alias.alias = 'test'", Vec::new());
// Currently an error, could be skipped instead, in that case the Ok(..) result should be
// tested a bit.
// Currently an error, could be skipped instead, in that case the Ok(..) result
// should be tested a bit.
assert!(result.is_err());
}
}

0 comments on commit af17a60

Please sign in to comment.