Skip to content

Commit

Permalink
tests: move attach to its own test
Browse files Browse the repository at this point in the history
  • Loading branch information
psarna committed Jan 17, 2024
1 parent 4a3803e commit 492f5b4
Showing 1 changed file with 38 additions and 2 deletions.
40 changes: 38 additions & 2 deletions libsql-server/tests/namespaces/meta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,43 @@ fn meta_store() {
foo_conn.execute("select 1", ()).await.unwrap();
}

// STEP 4: try attaching a database
Ok(())
});

sim.run().unwrap();
}

#[test]
fn meta_attach() {
let mut sim = Builder::new().build();
let tmp = tempdir().unwrap();
make_primary(&mut sim, tmp.path().to_path_buf());

sim.client("client", async {
let client = Client::new();

// STEP 1: create namespace and check that it can be read from
client
.post(
"http://primary:9090/v1/namespaces/foo/create",
json!({
"max_db_size": "5mb"
}),
)
.await?;

{
let foo = Database::open_remote_with_connector(
"http://foo.primary:8080",
"",
TurmoilConnector,
)?;
let foo_conn = foo.connect()?;

foo_conn.execute("select 1", ()).await.unwrap();
}

// STEP 2: try attaching a database
{
let foo = Database::open_remote_with_connector(
"http://foo.primary:8080",
Expand All @@ -149,7 +185,7 @@ fn meta_store() {
foo_conn.execute("attach foo as foo", ()).await.unwrap_err();
}

// STEP 5: update config to allow attaching databases
// STEP 3: update config to allow attaching databases
client
.post(
"http://primary:9090/v1/namespaces/foo/config",
Expand Down

0 comments on commit 492f5b4

Please sign in to comment.