Skip to content
Open
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
12 changes: 12 additions & 0 deletions crates/walgit-config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1079,6 +1079,10 @@ impl Config {
pub fn validate(&self) -> Result<()> {
self.refs.validate()?;
self.packs.validate()?;
anyhow::ensure!(
self.server.max_concurrent_per_repo > 0,
"server.max_concurrent_per_repo must be positive"
);
anyhow::ensure!(
self.packfile_uri.uri_min_bytes.as_u64() > 0,
"packfile_uri.uri_min_bytes must be positive"
Expand Down Expand Up @@ -1354,6 +1358,14 @@ mod tests {
assert_eq!(back.store.bucket, c.store.bucket);
}

#[test]
fn zero_per_repo_concurrency_is_rejected() {
let mut c = Config::default();
c.server.max_concurrent_per_repo = 0;
let err = c.validate().unwrap_err().to_string();
assert!(err.contains("server.max_concurrent_per_repo must be positive"));
}

#[test]
fn example_configurations_parse_and_validate() {
Config::parse(include_str!("../../../walgit.example.toml")).unwrap();
Expand Down