test: test for config file creation and default config file parsing (#459)

This commit is contained in:
SteveLauC
2023-06-23 17:04:05 +08:00
committed by GitHub
parent a6195d284c
commit 06cb88a1a1
2 changed files with 20 additions and 0 deletions

View File

@@ -57,3 +57,10 @@ jobs:
# token: ${{ secrets.CODECOV_TOKEN }} # token: ${{ secrets.CODECOV_TOKEN }}
files: ./lcov.info files: ./lcov.info
fail_ci_if_error: true fail_ci_if_error: true
- name: Test creation of config file
run: |
CONFIG_PATH=~/.config/topgrade.toml;
if [ -f "$CONFIG_PATH" ]; then rm $CONFIG_PATH; fi
cargo build;
./target/debug/topgrade --dry-run --only system;
stat $CONFIG_PATH;

View File

@@ -1515,3 +1515,16 @@ impl Config {
self.opt.custom_commands.iter().any(|s| s == name) self.opt.custom_commands.iter().any(|s| s == name)
} }
} }
#[cfg(test)]
mod test {
use crate::config::ConfigFile;
/// Test the default configuration in `config.example.toml` is valid.
#[test]
fn test_default_config() {
let str = include_str!("../config.example.toml");
assert!(toml::from_str::<ConfigFile>(str).is_ok());
}
}