Skip to content

Commit e8745cb

Browse files
committed
fix blocking tests
1 parent 2d272f2 commit e8745cb

File tree

2 files changed

+37
-32
lines changed

2 files changed

+37
-32
lines changed

src/blocking/collection.rs

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -305,19 +305,23 @@ mod test {
305305
collection.lock().unwrap();
306306
}
307307

308-
#[tokio::test]
309-
#[ignore]
310-
async fn should_get_collection_by_path() {
311-
let ss = crate::SecretService::connect(EncryptionType::Plain)
312-
.await
313-
.unwrap();
314-
let collection = ss.get_default_collection().await.unwrap();
315-
let label = collection.get_label().await.unwrap();
316-
317-
// get collection by path
318-
let path = collection.collection_path.clone();
319-
let collection_prime = ss.get_collection_by_path(path).await.unwrap();
320-
let label_prime = collection_prime.get_label().await.unwrap();
321-
assert_eq!(label, label_prime);
308+
#[test]
309+
fn should_get_collection_by_path() {
310+
let path: OwnedObjectPath;
311+
let label: String;
312+
// get the default collection on one blocking call, remember its path and label
313+
{
314+
let ss = SecretService::connect(EncryptionType::Plain).unwrap();
315+
let collection = ss.get_default_collection().unwrap();
316+
label = collection.get_label().unwrap();
317+
path = collection.collection_path.clone();
318+
}
319+
// get collection by path on another blocking call, check that the label is the same
320+
{
321+
let ss = SecretService::connect(EncryptionType::Plain).unwrap();
322+
let collection_prime = ss.get_collection_by_path(path).unwrap();
323+
let label_prime = collection_prime.get_label().unwrap();
324+
assert_eq!(label, label_prime);
325+
}
322326
}
323327
}

src/blocking/item.rs

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -213,24 +213,25 @@ mod test {
213213
item.delete().unwrap();
214214
}
215215

216-
#[tokio::test]
217-
async fn should_get_item_by_path() {
218-
let ss = SecretService::connect(EncryptionType::Plain).unwrap();
219-
let collection = ss.get_default_collection().unwrap();
220-
let item = create_test_default_item(&collection);
221-
222-
// Set label to test and check
223-
item.set_label("Tester").unwrap();
224-
let label = item.get_label().unwrap();
225-
assert_eq!(label, "Tester");
226-
227-
// get item by path and check label
228-
let path = item.item_path.clone();
229-
let item_prime = ss.get_item_by_path(path).unwrap();
230-
let label_prime = item_prime.get_label().unwrap();
231-
assert_eq!(label_prime, label);
232-
233-
item.delete().unwrap();
216+
#[test]
217+
fn should_get_item_by_path() {
218+
let path: OwnedObjectPath;
219+
// first create the item on one blocking call, set its label, and get its path
220+
{
221+
let ss = SecretService::connect(EncryptionType::Plain).unwrap();
222+
let collection = ss.get_default_collection().unwrap();
223+
let item = create_test_default_item(&collection);
224+
item.set_label("Tester").unwrap();
225+
path = item.item_path.clone();
226+
}
227+
// now get the item by path on another blocking call, check its label, and delete it
228+
{
229+
let ss = SecretService::connect(EncryptionType::Plain).unwrap();
230+
let item = ss.get_item_by_path(path).unwrap();
231+
let label = item.get_label().unwrap();
232+
assert_eq!(label, "Tester");
233+
item.delete().unwrap();
234+
}
234235
}
235236

236237
#[test]

0 commit comments

Comments
 (0)