mirror of
https://github.com/Universal-Debloater-Alliance/universal-android-debloater-next-generation.git
synced 2026-08-09 15:19:11 +02:00
build(test): added some more unit tests
This commit is contained in:
parent
3727469c8f
commit
146a15943c
2 changed files with 73 additions and 0 deletions
|
|
@ -99,3 +99,56 @@ impl Config {
|
|||
Self::default()
|
||||
}
|
||||
}
|
||||
|
||||
//write unit tests:
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use std::path::Path;
|
||||
|
||||
// create a clean default config file for testing
|
||||
fn create_default_config_file() {
|
||||
let toml = toml::to_string(&Config::default()).unwrap();
|
||||
fs::write(&*CONFIG_FILE, toml).expect("Could not write config file to disk!");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_create_default_config_file() {
|
||||
create_default_config_file();
|
||||
assert!(CONFIG_FILE.exists());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_load_configuration_file(){
|
||||
create_default_config_file();
|
||||
let config = Config::load_configuration_file();
|
||||
assert_eq!(config.devices.len(), 0);
|
||||
assert_eq!(config.general.theme, Theme::default().to_string());
|
||||
assert_eq!(config.general.expert_mode, false);
|
||||
assert_eq!(config.general.backup_folder, CACHE_DIR.join("backups"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_save_changes() {
|
||||
let mut settings = Settings::default();
|
||||
let device_id = "test_device".to_string();
|
||||
settings.device.device_id = device_id.clone();
|
||||
Config::save_changes(&settings, &device_id);
|
||||
let config = Config::load_configuration_file();
|
||||
assert_eq!(config.devices[0].device_id, device_id);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_default_config() {
|
||||
let config = Config::default();
|
||||
assert_eq!(config.devices.len(), 0);
|
||||
assert_eq!(config.general.theme, Theme::default().to_string());
|
||||
assert_eq!(config.general.expert_mode, false);
|
||||
assert_eq!(config.general.backup_folder, CACHE_DIR.join("backups"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_config_file_path() {
|
||||
assert_eq!(&*CONFIG_FILE, Path::new(&*CONFIG_DIR.join("config.toml")));
|
||||
}
|
||||
}
|
||||
|
|
@ -573,3 +573,23 @@ impl rule::StyleSheet for Theme {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Unit tests
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_palette() {
|
||||
let palette = Theme::default().palette();
|
||||
|
||||
assert_ne!(palette.base.background, Color::BLACK);
|
||||
assert_ne!(palette.base.foreground, Color::BLACK);
|
||||
assert_ne!(palette.normal.primary, Color::BLACK);
|
||||
assert_ne!(palette.normal.surface, Color::BLACK);
|
||||
assert_ne!(palette.bright.primary, Color::BLACK);
|
||||
assert_ne!(palette.bright.surface, Color::BLACK);
|
||||
assert_ne!(palette.normal.error, Color::BLACK);
|
||||
assert_ne!(palette.bright.error, Color::BLACK);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue