Skip to content

Commit 376a89d

Browse files
authored
test: add hrana intp_stream test (#1593)
* test: add hrana intp_stream test * fix test
1 parent 5e6afb3 commit 376a89d

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

libsql-server/tests/hrana/batch.rs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use std::time::Duration;
22

3+
use futures::StreamExt;
34
use insta::assert_json_snapshot;
45
use libsql::{params, Database};
56
use libsql_server::hrana_proto::{Batch, BatchStep, Stmt};
@@ -316,3 +317,41 @@ fn stats_legacy() {
316317

317318
sim.run().unwrap();
318319
}
320+
321+
#[test]
322+
fn stream() {
323+
let mut sim = turmoil::Builder::new()
324+
.simulation_duration(Duration::from_secs(1000))
325+
.build();
326+
sim.host("primary", super::make_standalone_server);
327+
sim.client("client", async {
328+
let db = Database::open_remote_with_connector("http://primary:8080", "", TurmoilConnector)?;
329+
let conn = db.connect()?;
330+
331+
conn.execute("create table t(x text)", ()).await?;
332+
conn.execute("insert into t(x) values(?)", params!["hello"])
333+
.await?;
334+
335+
conn.execute("insert into t(x) values(?)", params!["hello"])
336+
.await?;
337+
338+
conn.execute("insert into t(x) values(?)", params!["hello"])
339+
.await?;
340+
341+
conn.execute("insert into t(x) values(?)", params!["hello"])
342+
.await?;
343+
344+
let rows = conn
345+
.query("select * from t where x = ?", params!["hello"])
346+
.await?
347+
.into_stream();
348+
349+
let rows = rows.collect::<Vec<_>>().await;
350+
351+
assert_eq!(rows.len(), 4);
352+
353+
Ok(())
354+
});
355+
356+
sim.run().unwrap();
357+
}

0 commit comments

Comments
 (0)