mirror of
https://github.com/Hopiu/lychee.git
synced 2026-04-05 14:01:00 +00:00
fix: Add accept option to merged config (#1344)
This commit is contained in:
parent
8aa9081f1a
commit
0d0be52844
1 changed files with 24 additions and 1 deletions
|
|
@ -148,7 +148,7 @@ impl LycheeOptions {
|
|||
}
|
||||
|
||||
#[allow(clippy::struct_excessive_bools)]
|
||||
#[derive(Parser, Debug, Deserialize, Clone)]
|
||||
#[derive(Parser, Debug, Deserialize, Clone, Default)]
|
||||
pub(crate) struct Config {
|
||||
/// Verbose program output
|
||||
#[clap(flatten)]
|
||||
|
|
@ -452,6 +452,7 @@ impl Config {
|
|||
require_https: false;
|
||||
cookie_jar: None;
|
||||
include_fragments: false;
|
||||
accept: AcceptSelector::default();
|
||||
}
|
||||
|
||||
if self
|
||||
|
|
@ -469,3 +470,25 @@ impl Config {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_accept_status_codes() {
|
||||
let toml = Config {
|
||||
accept: AcceptSelector::from_str("200..=204, 429, 500").unwrap(),
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
let mut cli = Config::default();
|
||||
cli.merge(toml);
|
||||
|
||||
assert!(cli.accept.contains(429));
|
||||
assert!(cli.accept.contains(200));
|
||||
assert!(cli.accept.contains(203));
|
||||
assert!(cli.accept.contains(204));
|
||||
assert!(!cli.accept.contains(205));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue