mirror of
https://github.com/tealdeer-rs/tealdeer.git
synced 2026-08-09 09:49:10 +02:00
Move existing tests from config module into test submodule
This commit is contained in:
parent
94f9030d36
commit
7e014093cf
1 changed files with 33 additions and 33 deletions
|
|
@ -623,43 +623,43 @@ pub fn make_default_config(path: Option<&Path>) -> Result<PathBuf> {
|
|||
Ok(config_file_path)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_serialize_deserialize() {
|
||||
let raw_config = RawConfig::default();
|
||||
let serialized = toml::to_string(&raw_config).unwrap();
|
||||
let deserialized: RawConfig = toml::from_str(&serialized).unwrap();
|
||||
assert_eq!(raw_config, deserialized);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_relative_path_resolution() {
|
||||
let mut raw_config = RawConfig::default();
|
||||
raw_config.directories.cache_dir = Some("../cache".into());
|
||||
raw_config.directories.custom_pages_dir = Some("../custom_pages".into());
|
||||
|
||||
let config = Config::from_raw(
|
||||
&raw_config,
|
||||
PathWithSource {
|
||||
path: PathBuf::from("/path/to/config/config.toml"),
|
||||
source: PathSource::OsConvention,
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(
|
||||
config.directories.cache_dir.path(),
|
||||
Path::new("/path/to/config/../cache")
|
||||
);
|
||||
assert_eq!(
|
||||
config.directories.custom_pages_dir.unwrap().path(),
|
||||
Path::new("/path/to/config/../custom_pages")
|
||||
);
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn serialize_deserialize() {
|
||||
let raw_config = RawConfig::default();
|
||||
let serialized = toml::to_string(&raw_config).unwrap();
|
||||
let deserialized: RawConfig = toml::from_str(&serialized).unwrap();
|
||||
assert_eq!(raw_config, deserialized);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn relative_path_resolution() {
|
||||
let mut raw_config = RawConfig::default();
|
||||
raw_config.directories.cache_dir = Some("../cache".into());
|
||||
raw_config.directories.custom_pages_dir = Some("../custom_pages".into());
|
||||
|
||||
let config = Config::from_raw(
|
||||
&raw_config,
|
||||
PathWithSource {
|
||||
path: PathBuf::from("/path/to/config/config.toml"),
|
||||
source: PathSource::OsConvention,
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(
|
||||
config.directories.cache_dir.path(),
|
||||
Path::new("/path/to/config/../cache")
|
||||
);
|
||||
assert_eq!(
|
||||
config.directories.custom_pages_dir.unwrap().path(),
|
||||
Path::new("/path/to/config/../custom_pages")
|
||||
);
|
||||
}
|
||||
|
||||
mod language {
|
||||
use super::*;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue