Skip to content

Commit bb832b3

Browse files
test(jco): add test for stream of list<record>
1 parent 24b3e14 commit bb832b3

3 files changed

Lines changed: 25 additions & 1 deletion

File tree

crates/test-components/src/bin/stream_rx.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,12 @@ impl use_stream_async::Guest for Component {
123123
) -> Vec<Vec<[u32; 5]>> {
124124
read_async_values(rx).await
125125
}
126+
127+
async fn read_stream_values_list_record(
128+
rx: StreamReader<Vec<ExampleRecord>>,
129+
) -> Vec<Vec<ExampleRecord>> {
130+
read_async_values(rx).await
131+
}
126132
}
127133

128134
async fn read_async_values<T>(mut rx: StreamReader<T>) -> Vec<T> {

crates/test-components/wit/all.wit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ interface use-stream-async {
229229
read-stream-values-list-u8: async func(s: stream<list<u8>>) -> list<list<u8>>;
230230
read-stream-values-list-string: async func(s: stream<list<string>>) -> list<list<string>>;
231231
read-stream-values-fixed-list-u32: async func(s: stream<list<list<u32, 5>>>) -> list<list<list<u32, 5>>>;
232-
// read-stream-values-list-record: async func(s: stream<list<example-record>>) -> list<list<example-record>>;
232+
read-stream-values-list-record: async func(s: stream<list<example-record>>) -> list<list<example-record>>;
233233

234234
// // NOTE: the check here will be whether the resources are disposed inside the component properly
235235
// read-stream-values-example-resource-own: async func(s: stream<example-resource>);

packages/jco/test/p3/stream-lowers.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,4 +372,22 @@ suite("stream<T> lowers", () => {
372372
],
373373
]);
374374
});
375+
376+
test.concurrent("list<example-record>", async () => {
377+
assert.instanceOf(instance["jco:test-components/use-stream-async"].readStreamValuesListRecord, AsyncFunction);
378+
379+
let vals = [
380+
[ { id: 3, idStr: "three" },
381+
{ id: 2, idStr: "two" },
382+
{ id: 1, idStr: "one" }, ],
383+
[ { id: 1, idStr: "one-one" },
384+
{ id: 2, idStr: "two-two" },
385+
{ id: 3, idStr: "three-three" }, ],
386+
];
387+
let returnedVals = await instance["jco:test-components/use-stream-async"].readStreamValuesListRecord(
388+
createReadableStreamFromValues(vals),
389+
);
390+
assert.deepEqual(returnedVals, vals);
391+
});
392+
375393
});

0 commit comments

Comments
 (0)