unittests mpv

This commit is contained in:
Bel LaPointe
2023-03-16 14:31:21 -06:00
parent 7e674b509a
commit 9258eeb650
3 changed files with 143 additions and 0 deletions

View File

@@ -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());
}
}