Skip to content

Commit

Permalink
dbus/tests: Create a default collection if not found
Browse files Browse the repository at this point in the history
  • Loading branch information
bilelmoussaoui committed Jan 21, 2024
1 parent bcc4c76 commit 4b2889b
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions client/src/dbus/collection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ mod tests {
#[cfg(feature = "local_tests")]
use super::*;
#[cfg(feature = "local_tests")]
use crate::dbus::Service;
use crate::dbus::{self, Service};

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

let collection = service.default_collection().await.unwrap();
let collection = match service.default_collection().await {
Err(dbus::Error::NotFound(_)) => {
service
.create_collection("Default", Some(dbus::DEFAULT_COLLECTION))
.await
}
e => e,
}
.unwrap();
let n_items = collection.items().await.unwrap().len();
let n_search_items = collection.search_items(&attributes).await.unwrap().len();

Expand Down

0 comments on commit 4b2889b

Please sign in to comment.