Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions libsql-server/tests/hrana/batch.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::time::Duration;

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

sim.run().unwrap();
}

#[test]
fn stream() {
let mut sim = turmoil::Builder::new()
.simulation_duration(Duration::from_secs(1000))
.build();
sim.host("primary", super::make_standalone_server);
sim.client("client", async {
let db = Database::open_remote_with_connector("http://primary:8080", "", TurmoilConnector)?;
let conn = db.connect()?;

conn.execute("create table t(x text)", ()).await?;
conn.execute("insert into t(x) values(?)", params!["hello"])
.await?;

conn.execute("insert into t(x) values(?)", params!["hello"])
.await?;

conn.execute("insert into t(x) values(?)", params!["hello"])
.await?;

conn.execute("insert into t(x) values(?)", params!["hello"])
.await?;

let rows = conn
.query("select * from t where x = ?", params!["hello"])
.await?
.into_stream();

let rows = rows.collect::<Vec<_>>().await;

assert_eq!(rows.len(), 4);

Ok(())
});

sim.run().unwrap();
}