Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
A6GibKm committed Jan 2, 2024
1 parent edc2629 commit 44e3e55
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ async fn run() -> oo7::Result<()> {
// Find a stored secret
let items = keyring
.search_items(HashMap::from([("attribute", "attribute_value")]))
.search_items(&HashMap::from([("attribute", "attribute_value")]))
.await?;
// Delete a stored secret
keyring
.delete(HashMap::from([("attribute", "attribute_value")]))
.delete(&HashMap::from([("attribute", "attribute_value")]))
.await?;
// Unlock the collection if the Secret Service is used
Expand Down Expand Up @@ -82,7 +82,7 @@ fn main() {
let items = KEYRING
.get()
.unwrap()
.search_items(HashMap::from([("attribute", "attribute_value")]))
.search_items(&HashMap::from([("attribute", "attribute_value")]))
.await;
});
}
Expand Down
2 changes: 1 addition & 1 deletion client/examples/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ async fn main() -> oo7::Result<()> {
.await?;

let items = keyring
.search_items(HashMap::from([("attr", "value")]))
.search_items(&HashMap::from([("attr", "value")]))
.await?;

for item in items {
Expand Down
2 changes: 1 addition & 1 deletion client/examples/basic_2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ async fn main() -> oo7::Result<()> {
let items = KEYRING
.get()
.unwrap()
.search_items(HashMap::from([("attr", "value")]))
.search_items(&HashMap::from([("attr", "value")]))
.await?;

for item in items {
Expand Down
2 changes: 1 addition & 1 deletion client/examples/dbus_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ async fn main() -> oo7::Result<()> {
let mut attributes = HashMap::new();
attributes.insert("type", "token");
let collection = service.default_collection().await?;
let items = collection.search_items(attributes).await?;
let items = collection.search_items(&attributes).await?;
for item in items {
println!("{}", item.label().await?);
println!("{}", item.is_locked().await?);
Expand Down
2 changes: 1 addition & 1 deletion client/src/dbus/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
//! .await?;
//!
//! // Retrieve it later thanks to it attributes
//! let items = collection.search_items(attributes).await?;
//! let items = collection.search_items(&attributes).await?;
//! let item = items.first().unwrap();
//! assert_eq!(*item.secret().await?, b"password");
//!
Expand Down
8 changes: 4 additions & 4 deletions client/src/portal/api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,11 +330,11 @@ mod tests {
.items
.push(Item::new(String::from("Label"), needle.clone(), b"MyPassword").encrypt(&key)?);

assert_eq!(keyring.search_items(needle.clone(), &key)?.len(), 1);
assert_eq!(keyring.search_items(&needle, &key)?.len(), 1);

keyring.remove_items(needle.clone(), &key)?;
keyring.remove_items(&needle, &key)?;

assert_eq!(keyring.search_items(needle, &key)?.len(), 0);
assert_eq!(keyring.search_items(&needle, &key)?.len(), 0);

Ok(())
}
Expand All @@ -360,7 +360,7 @@ mod tests {

let loaded_keyring = Keyring::try_from(blob.as_slice())?;
let loaded_items =
loaded_keyring.search_items(HashMap::from([("my-tag", "my tag value")]), &key)?;
loaded_keyring.search_items(&HashMap::from([("my-tag", "my tag value")]), &key)?;

assert_eq!(*loaded_items[0].secret(), "A Password".as_bytes());

Expand Down
4 changes: 2 additions & 2 deletions client/src/portal/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
//! .await?;
//!
//! let items = keyring
//! .search_items(HashMap::from([("account", "alice")]))
//! .search_items(&HashMap::from([("account", "alice")]))
//! .await?;
//! assert_eq!(*items[0].secret(), b"My Password");
//!
//! keyring
//! .delete(HashMap::from([("account", "alice")]))
//! .delete(&HashMap::from([("account", "alice")]))
//! .await?;
//! # Ok(())
//! # }
Expand Down

0 comments on commit 44e3e55

Please sign in to comment.