Skip to content

Commit

Permalink
Fix overriding license header bug (#4488)
Browse files Browse the repository at this point in the history
* Override header to None when path len = 0

* Add regression test

* Ensure nightly
  • Loading branch information
cmichi committed Oct 24, 2020
1 parent 6a78247 commit fa9d974
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/config/config_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,8 @@ macro_rules! create_config {
Err(msg) => eprintln!("Warning for license template file {:?}: {}",
lt_path, msg),
}
} else {
self.license_template = None;
}
}
}
Expand Down
12 changes: 12 additions & 0 deletions src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,18 @@ mod test {
assert!(config.license_template.is_some());
}

#[test]
fn test_override_existing_license_with_no_license() {
if !crate::is_nightly_channel!() {
return;
}
let toml = r#"license_template_path = "tests/license-template/lt.txt""#;
let mut config = Config::from_toml(toml, Path::new("")).unwrap();
assert!(config.license_template.is_some());
config.override_value("license_template_path", "");
assert!(config.license_template.is_none());
}

#[test]
fn test_dump_default_config() {
let default_config = format!(
Expand Down

0 comments on commit fa9d974

Please sign in to comment.