Skip to content

Commit f3ad074

Browse files
fix tests
1 parent 946a083 commit f3ad074

2 files changed

Lines changed: 13 additions & 7 deletions

File tree

sdks/rust/tests/test-client/src/test_handlers.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ pub async fn dispatch(test: &str, db_name: &str) {
8787

8888
// "resubscribe" => exec_resubscribe(),
8989
//
90+
"reauth" => exec_reauth(db_name).await,
9091
"reauth-part-1" => exec_reauth_part_1(db_name).await,
9192
"reauth-part-2" => exec_reauth_part_2(db_name).await,
9293

@@ -1722,8 +1723,13 @@ async fn exec_insert_primitives_as_strings(db_name: &str) {
17221723
// }
17231724

17241725
#[cfg(not(target_arch = "wasm32"))]
1725-
fn creds_store() -> credentials::File {
1726-
credentials::File::new("rust-sdk-test")
1726+
fn creds_store(db_name: &str) -> credentials::File {
1727+
credentials::File::new(format!("rust-sdk-test-{db_name}"))
1728+
}
1729+
1730+
async fn exec_reauth(db_name: &str) {
1731+
exec_reauth_part_1(db_name).await;
1732+
exec_reauth_part_2(db_name).await;
17271733
}
17281734

17291735
/// Part of the `reauth` test, this connects to Spacetime to get new credentials,
@@ -1735,10 +1741,11 @@ async fn exec_reauth_part_1(db_name: &str) {
17351741
let name = db_name.to_owned();
17361742

17371743
let save_result = test_counter.add_test("save-credentials");
1744+
let creds = creds_store(db_name);
17381745

17391746
DbConnection::builder()
1740-
.on_connect(|_, _identity, token| {
1741-
save_result(creds_store().save(token).map_err(Into::into));
1747+
.on_connect(move |_, _identity, token| {
1748+
save_result(creds.save(token).map_err(Into::into));
17421749
})
17431750
.on_connect_error(|_ctx, error| panic!("Connect failed: {error:?}"))
17441751
.with_database_name(name)
@@ -1762,7 +1769,7 @@ async fn exec_reauth_part_2(db_name: &str) {
17621769

17631770
let creds_match_result = test_counter.add_test("creds-match");
17641771

1765-
let token = creds_store().load().unwrap().unwrap();
1772+
let token = creds_store(db_name).load().unwrap().unwrap();
17661773

17671774
DbConnection::builder()
17681775
.on_connect({

sdks/rust/tests/test.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,8 +277,7 @@ macro_rules! declare_tests_with_suffix {
277277

278278
#[test]
279279
fn reauth() {
280-
make_test("reauth-part-1").run();
281-
make_test("reauth-part-2").run();
280+
make_test("reauth").run();
282281
}
283282

284283
#[test]

0 commit comments

Comments
 (0)