Skip to content

Commit

Permalink
fix: Add accept option to merged config (#1344)
Browse files Browse the repository at this point in the history
  • Loading branch information
Techassi authored Jan 9, 2024
1 parent 8aa9081 commit 0d0be52
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion lychee-bin/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -452,6 +452,7 @@ impl Config {
require_https: false;
cookie_jar: None;
include_fragments: false;
accept: AcceptSelector::default();
}

if self
Expand All @@ -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));
}
}

0 comments on commit 0d0be52

Please sign in to comment.