Skip to content

Commit

Permalink
Fix attribute roundtrip tests
Browse files Browse the repository at this point in the history
  • Loading branch information
complexspaces committed Nov 25, 2022
1 parent d31cc9f commit 9602c50
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 20 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
bin
target
Cargo.lock

.vscode/
28 changes: 18 additions & 10 deletions src/blocking/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,14 +234,18 @@ mod test {
"text/plain",
)
.unwrap();

let attributes = item.get_attributes().unwrap();

// We do not compare exact attributes, since the secret service provider could add its own
// at any time. Instead, we only check that the ones we provided are returned back.
assert_eq!(
attributes,
HashMap::from([(
String::from("test_attributes_in_item"),
String::from("test")
)])
attributes
.get("test_attributes_in_item")
.map(String::as_str),
Some("test")
);

item.delete().unwrap();
}

Expand All @@ -255,14 +259,18 @@ mod test {
item.set_attributes(HashMap::new()).unwrap();
item.set_attributes(HashMap::from([("test_attributes_in_item_get", "test")]))
.unwrap();

let attributes = item.get_attributes().unwrap();

// We do not compare exact attributes, since the secret service provider could add its own
// at any time. Instead, we only check that the ones we provided are returned back.
assert_eq!(
attributes,
HashMap::from([(
String::from("test_attributes_in_item_get"),
String::from("test")
)])
attributes
.get("test_attributes_in_item_get")
.map(String::as_str),
Some("test")
);

item.delete().unwrap();
}

Expand Down
28 changes: 18 additions & 10 deletions src/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,14 +248,18 @@ mod test {
)
.await
.unwrap();

let attributes = item.get_attributes().await.unwrap();

// We do not compare exact attributes, since the secret service provider could add its own
// at any time. Instead, we only check that the ones we provided are returned back.
assert_eq!(
attributes,
HashMap::from([(
String::from("test_attributes_in_item"),
String::from("test")
)])
attributes
.get("test_attributes_in_item")
.map(String::as_str),
Some("test")
);

item.delete().await.unwrap();
}

Expand All @@ -270,14 +274,18 @@ mod test {
item.set_attributes(HashMap::from([("test_attributes_in_item_get", "test")]))
.await
.unwrap();

let attributes = item.get_attributes().await.unwrap();

// We do not compare exact attributes, since the secret service provider could add its own
// at any time. Instead, we only check that the ones we provided are returned back.
assert_eq!(
attributes,
HashMap::from([(
String::from("test_attributes_in_item_get"),
String::from("test")
)])
attributes
.get("test_attributes_in_item_get")
.map(String::as_str),
Some("test")
);

item.delete().await.unwrap();
}

Expand Down

0 comments on commit 9602c50

Please sign in to comment.