stdin, stdout stupid case ok
parent
60b5574ca7
commit
a293297d6e
|
|
@ -66,7 +66,7 @@ mod tests {
|
|||
|
||||
#[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());
|
||||
build_config_yaml("./src/testdata/config-kinesis-to-kafka.json".to_string()).unwrap();
|
||||
build_config_yaml("./src/testdata/config-stdin-to-stdout.yaml".to_string()).unwrap();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ impl InputEngine for InputEngineStdin {
|
|||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
mod test_input {
|
||||
use super::*;
|
||||
|
||||
struct InputEngineTest {}
|
||||
|
|
@ -43,3 +43,43 @@ mod test {
|
|||
assert_eq!("hello world".to_string(), engine.get());
|
||||
}
|
||||
}
|
||||
|
||||
pub trait OutputEngine {
|
||||
fn put(&self, v: String);
|
||||
}
|
||||
|
||||
pub fn build_output_engine(cfg: &Engine) -> Result<Box<dyn OutputEngine>, String> {
|
||||
match cfg.name.as_str() {
|
||||
"stdout" => return Ok(Box::new(OutputEngineStdout{})),
|
||||
_ => return Err("unknown output engine name".to_string() + &cfg.name),
|
||||
}
|
||||
}
|
||||
|
||||
struct OutputEngineStdout {}
|
||||
|
||||
impl OutputEngine for OutputEngineStdout {
|
||||
fn put(&self, v: String) {
|
||||
println!("{}", v);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test_output {
|
||||
use super::*;
|
||||
|
||||
struct OutputEngineTest {}
|
||||
impl OutputEngine for OutputEngineTest {
|
||||
fn put(&self, _v: String) {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_output_engine_impl() {
|
||||
let output_engine_test = OutputEngineTest{};
|
||||
_test_output_engine_impl(&output_engine_test);
|
||||
}
|
||||
|
||||
fn _test_output_engine_impl(engine: &dyn OutputEngine) {
|
||||
engine.put("teehee".to_string());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ mod engine;
|
|||
fn main() {
|
||||
let cfg = config::build_config().unwrap();
|
||||
let input_engine = engine::build_input_engine(&cfg.streams.input.engine);
|
||||
let output_engine = engine::build_output_engine(&cfg.streams.output.engine);
|
||||
println!("{:?} => {}", cfg.streams.input.engine.name, input_engine.is_ok());
|
||||
println!("{}", input_engine.unwrap().get());
|
||||
println!("{:?} => {}", cfg.streams.output.engine.name, output_engine.is_ok());
|
||||
output_engine.unwrap().put(input_engine.unwrap().get());
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue