unittests mpv
This commit is contained in:
@@ -1,3 +1,7 @@
|
||||
use serde::Serialize;
|
||||
use serde::Deserialize;
|
||||
use std::fs;
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct Config {
|
||||
streams: Streams,
|
||||
@@ -20,6 +24,15 @@ struct Engine {
|
||||
}
|
||||
|
||||
pub fn build_config() -> Config {
|
||||
return build_config_std()
|
||||
}
|
||||
|
||||
fn build_config_yaml(path: String) -> Config {
|
||||
let buffer: String = fs::read_to_string(path).unwrap();
|
||||
return serde_yaml::from_str(&buffer).unwrap();
|
||||
}
|
||||
|
||||
fn build_config_std() -> Config {
|
||||
return Config {
|
||||
streams: Streams{
|
||||
input: Stream {
|
||||
@@ -29,5 +42,21 @@ pub fn build_config() -> Config {
|
||||
engine: Engine{ name: String::from("stdout") },
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_build_config_std() {
|
||||
build_config_std();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_build_config_yaml() {
|
||||
build_config_yaml("./src/testdata/config-kinesis-to-kafka.json".to_string());
|
||||
build_config_yaml("./src/testdata/config-stdin-to-stdout.yaml".to_string());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user