mirror of
https://github.com/fabro-sh/fabro.git
synced 2026-09-16 23:43:10 +00:00
fix(lint): clean up fabro-config test clippy warnings
- Drop the fabro_types::Combine re-export from fabro-config/lib.rs (unused externally after Stage 3 replaced the legacy Combine-based merge with the v2 merge matrix) - Replace absolute `fabro_types::settings::v2::InterpString` paths in fabro-config/src/config.rs and merge.rs test blocks with a scoped `use` import, satisfying clippy::absolute_paths - fabro-config/src/merge.rs tests: use `!contains_key`, drop redundant closures around InterpString::as_source, prefer indexing over get().unwrap() on the notifications HashMap - fabro-config/src/project.rs tests: switch the run.execution.retros fixture off raw string literal hashes (only simple content inside) and use ToString::to_string in the error-chain join expression
This commit is contained in:
parent
31db613aa0
commit
c6d515be44
4 changed files with 26 additions and 12 deletions
|
|
@ -151,6 +151,8 @@ impl ConfigLayer {
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use fabro_types::settings::v2::InterpString;
|
||||
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
|
|
@ -179,7 +181,7 @@ goal = "Do things"
|
|||
.run
|
||||
.as_ref()
|
||||
.and_then(|r| r.goal.as_ref())
|
||||
.map(fabro_types::settings::v2::InterpString::as_source)
|
||||
.map(InterpString::as_source)
|
||||
.as_deref(),
|
||||
Some("Do things")
|
||||
);
|
||||
|
|
@ -210,7 +212,7 @@ goal = "lower goal"
|
|||
.run
|
||||
.as_ref()
|
||||
.and_then(|r| r.goal.as_ref())
|
||||
.map(fabro_types::settings::v2::InterpString::as_source)
|
||||
.map(InterpString::as_source)
|
||||
.as_deref(),
|
||||
Some("higher goal")
|
||||
);
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ pub mod storage;
|
|||
pub mod user;
|
||||
|
||||
pub use config::ConfigLayer;
|
||||
pub use fabro_types::Combine;
|
||||
pub use fabro_util::path::expand_tilde;
|
||||
pub use home::Home;
|
||||
pub use storage::{RunScratch, ServerState, Storage};
|
||||
|
|
|
|||
|
|
@ -479,8 +479,9 @@ fn combine_server_integrations(
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use fabro_types::settings::v2::{InterpString, parse_settings_file};
|
||||
|
||||
use super::*;
|
||||
use fabro_types::settings::v2::parse_settings_file;
|
||||
|
||||
fn parse(input: &str) -> SettingsFile {
|
||||
parse_settings_file(input).expect("fixture should parse")
|
||||
|
|
@ -505,7 +506,7 @@ a = "higher"
|
|||
let inputs = merged.run.unwrap().inputs.unwrap();
|
||||
assert_eq!(inputs.len(), 1);
|
||||
assert_eq!(inputs.get("a"), Some(&toml::Value::String("higher".into())));
|
||||
assert!(inputs.get("b").is_none(), "lower key should be gone");
|
||||
assert!(!inputs.contains_key("b"), "lower key should be gone");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
@ -593,7 +594,11 @@ script = "higher-script"
|
|||
let hooks = merged.run.unwrap().hooks;
|
||||
assert_eq!(hooks.len(), 1);
|
||||
assert_eq!(
|
||||
hooks[0].script.as_ref().map(|s| s.as_source()).as_deref(),
|
||||
hooks[0]
|
||||
.script
|
||||
.as_ref()
|
||||
.map(InterpString::as_source)
|
||||
.as_deref(),
|
||||
Some("higher-script")
|
||||
);
|
||||
}
|
||||
|
|
@ -618,11 +623,19 @@ script = "higher-anon"
|
|||
let hooks = merged.run.unwrap().hooks;
|
||||
assert_eq!(hooks.len(), 2);
|
||||
assert_eq!(
|
||||
hooks[0].script.as_ref().map(|s| s.as_source()).as_deref(),
|
||||
hooks[0]
|
||||
.script
|
||||
.as_ref()
|
||||
.map(InterpString::as_source)
|
||||
.as_deref(),
|
||||
Some("lower-anon")
|
||||
);
|
||||
assert_eq!(
|
||||
hooks[1].script.as_ref().map(|s| s.as_source()).as_deref(),
|
||||
hooks[1]
|
||||
.script
|
||||
.as_ref()
|
||||
.map(InterpString::as_source)
|
||||
.as_deref(),
|
||||
Some("higher-anon")
|
||||
);
|
||||
}
|
||||
|
|
@ -643,7 +656,7 @@ events = ["...", "run.completed"]
|
|||
);
|
||||
let merged = combine_files(lower, higher);
|
||||
let run = merged.run.unwrap();
|
||||
let events = &run.notifications.get("ops").unwrap().events;
|
||||
let events = &run.notifications["ops"].events;
|
||||
assert_eq!(events.len(), 2);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -415,12 +415,12 @@ directory = "fabro/"
|
|||
#[test]
|
||||
fn parse_with_run_execution_retros() {
|
||||
let config = parse_project_config(
|
||||
r#"
|
||||
"
|
||||
_version = 1
|
||||
|
||||
[run.execution]
|
||||
retros = true
|
||||
"#,
|
||||
",
|
||||
)
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
|
|
@ -449,7 +449,7 @@ retros = true
|
|||
let err = parse_project_config("_version = 2\n").unwrap_err();
|
||||
let chain: String = err
|
||||
.chain()
|
||||
.map(|e| e.to_string())
|
||||
.map(ToString::to_string)
|
||||
.collect::<Vec<_>>()
|
||||
.join("; ");
|
||||
assert!(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue