Skip to content

Commit bf73d63

Browse files
dbus/tests: Create a default collection if not found
1 parent 0c2454f commit bf73d63

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

client/src/dbus/collection.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ mod tests {
255255
#[cfg(feature = "local_tests")]
256256
use super::*;
257257
#[cfg(feature = "local_tests")]
258-
use crate::dbus::Service;
258+
use crate::dbus::{self, Service};
259259

260260
#[cfg(feature = "local_tests")]
261261
async fn create_item(service: Service<'_>, encrypted: bool) {
@@ -268,7 +268,15 @@ mod tests {
268268
attributes.insert("type", value);
269269
let secret = "a password".as_bytes();
270270

271-
let collection = service.default_collection().await.unwrap();
271+
let collection = match service.default_collection().await {
272+
Err(dbus::Error::NotFound(_)) => {
273+
service
274+
.create_collection("Default", Some(dbus::DEFAULT_COLLECTION))
275+
.await
276+
}
277+
e => e,
278+
}
279+
.unwrap();
272280
let n_items = collection.items().await.unwrap().len();
273281
let n_search_items = collection.search_items(&attributes).await.unwrap().len();
274282

0 commit comments

Comments
 (0)