mirror of
https://gitlab.redox-os.org/redox-os/redox.git
synced 2026-06-17 23:44:17 +08:00
Test config
This commit is contained in:
parent
ab57937dd4
commit
e03e843abd
@ -3,6 +3,7 @@ use std::{collections::HashMap, env, fs, str::FromStr, sync::OnceLock};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Default, Clone, Deserialize, PartialEq, Serialize)]
|
||||
#[serde(default)]
|
||||
pub struct CookConfigOpt {
|
||||
/// whether to run offline
|
||||
pub offline: Option<bool>,
|
||||
@ -41,6 +42,7 @@ impl From<CookConfigOpt> for CookConfig {
|
||||
}
|
||||
|
||||
#[derive(Debug, Default, Deserialize, PartialEq, Serialize)]
|
||||
#[serde(default)]
|
||||
pub struct CookbookConfig {
|
||||
#[serde(rename = "cook")]
|
||||
cook_opt: CookConfigOpt,
|
||||
@ -155,6 +157,17 @@ mod tests {
|
||||
let _ = CONFIG.set(app_config);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_parse_cook() {
|
||||
let app_config: CookbookConfig = toml::from_str(
|
||||
"[cook]\n\
|
||||
offline = true\n",
|
||||
)
|
||||
.expect("Unable to parse test config");
|
||||
assert_eq!(app_config.cook_opt.offline, Some(true));
|
||||
assert_eq!(app_config.cook_opt.jobs, None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_exact_match() {
|
||||
setup_test_config();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user