| 91 | |
| 92 | #[rt::test] |
| 93 | async fn test_empty() -> Result<()> { |
| 94 | let mut graph = Builder::default() |
| 95 | .template( |
| 96 | r#" |
| 97 | main="test" |
| 98 | nodes=[{name="gb",ty="BinaryOpr"}] |
| 99 | [[graphs]] |
| 100 | name="sub" |
| 101 | inputs=[ |
| 102 | {name="a",cap=1,ports=["gb:a"]}, |
| 103 | {name="b",cap=1,ports=["gb:b"]} |
| 104 | ] |
| 105 | outputs=[{name="c",cap=1,ports=["gb:c"]}] |
| 106 | [[graphs]] |
| 107 | name="test" |
| 108 | inputs=[{name="inp",cap=1,ports=["t1:inp","t2:inp"]}] |
| 109 | outputs=[{name="out",cap=2,ports=["t3:out"]}] |
| 110 | connections=[ |
| 111 | {cap=1,ports=["t1:out", "sub:a"]}, |
| 112 | {cap=1,ports=["t2:out", "sub:b"]}, |
| 113 | {cap=1,ports=["t3:inp", "sub:c"]} |
| 114 | ] |
| 115 | nodes=[ |
| 116 | {name="sub",ty="sub"}, |
| 117 | {name="t1",ty="Transform"}, |
| 118 | {name="t2",ty="Transform"}, |
| 119 | {name="t3",ty="Transform"} |
| 120 | ] |
| 121 | "# |
| 122 | .to_owned(), |
| 123 | ) |
| 124 | .build()?; |
| 125 | let inp = graph.input("inp").unwrap(); |
| 126 | let out = graph.output("out").unwrap(); |
| 127 | let handle = graph.start(); |
| 128 | |
| 129 | inp.send(Envelope::new(1usize)).await.ok(); |
| 130 | inp.close(); |
| 131 | assert!(out.recv::<usize>().await.is_ok()); |
| 132 | assert!(out.recv::<usize>().await.is_ok()); |
| 133 | assert!(out.recv::<usize>().await.is_err()); |
| 134 | handle.await?; |
| 135 | Ok(()) |
| 136 | } |