From a67e597d1a17127898f360ebdd5a77968513ffb2 Mon Sep 17 00:00:00 2001 From: Julien Loudet Date: Mon, 20 Nov 2023 20:15:33 +0100 Subject: [PATCH] test(record): add serialization test for `DataFlowRecord` Signed-off-by: Julien Loudet --- zenoh-flow-records/src/tests.rs | 57 +++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/zenoh-flow-records/src/tests.rs b/zenoh-flow-records/src/tests.rs index 0219effe..82313eff 100644 --- a/zenoh-flow-records/src/tests.rs +++ b/zenoh-flow-records/src/tests.rs @@ -313,3 +313,60 @@ mapping: }; assert!(record.links.contains(&link_default)); } + +#[test] +fn test_serialize() { + let flow_yaml = r#" +name: base test flow + +sources: + - id: source-0 + description: test source + library: file:///home/zenoh-flow/libsource.so + outputs: + - out-0 + +operators: + - id: operator-1 + description: test operator + library: file:///home/zenoh-flow/liboperator.so + inputs: + - in-1 + outputs: + - out-1 + +sinks: + - id: sink-2 + description: test sink + library: file:///home/zenoh-flow/libsink.so + inputs: + - in-2 + +links: + - from: + node: source-0 + output: out-0 + to: + node: operator-1 + input: in-1 + + - from: + node: operator-1 + output: out-1 + to: + node: sink-2 + input: in-2 + "#; + + let flat_desc = FlattenedDataFlowDescriptor::try_flatten( + serde_yaml::from_str::(flow_yaml).unwrap(), + Vars::default(), + ) + .unwrap(); + + let default_runtime: RuntimeId = Uuid::new_v4().into(); + let record = DataFlowRecord::try_new(flat_desc, &default_runtime).unwrap(); + + let _string = serde_yaml::to_string(&record).expect("Failed to serialize to yaml"); + println!("{_string}"); +}