Fixed tests for FDB and SQL stores

This commit is contained in:
mdecimus
2025-05-23 17:07:36 +02:00
parent 2eb99ed3bd
commit c19d2ceb43
16 changed files with 113 additions and 42 deletions

View File

@@ -58,9 +58,9 @@ pub async fn test(test: &WebDavTest) {
"D:prop.D:lockdiscovery.D:activelock.D:owner.D:href",
"super-owner",
)
.with_value(
.with_any_value(
"D:prop.D:lockdiscovery.D:activelock.D:timeout",
"Second-456",
["Second-456", "Second-455"],
);
// Test 3: Creating a collection under an unmapped resource with a lock token should fail
@@ -116,14 +116,17 @@ pub async fn test(test: &WebDavTest) {
let props = response.properties(&href);
props
.get(DavProperty::WebDav(WebDavProperty::LockDiscovery))
.with_values([
.with_some_values([
"D:activelock.D:owner.D:href:super-owner",
"D:activelock.D:timeout:Second-456",
"D:activelock.D:depth:infinity",
format!("D:activelock.D:locktoken.D:href:{lock_token}").as_str(),
format!("D:activelock.D:lockroot.D:href:{path}").as_str(),
"D:activelock.D:locktype.D:write",
"D:activelock.D:lockscope.D:exclusive",
])
.with_any_values([
"D:activelock.D:timeout:Second-456",
"D:activelock.D:timeout:Second-455",
]);
}

View File

@@ -641,6 +641,24 @@ impl DavResponse {
self
}
pub fn with_any_value<'x>(
self,
query: &str,
expect: impl IntoIterator<Item = &'x str>,
) -> Self {
let expect = expect.into_iter().collect::<AHashSet<_>>();
if let Some(value) = self.find_keys(query).next() {
if !expect.contains(value) {
self.dump_response();
panic!("Expected {query} = {expect:?} but got {value:?}");
}
} else {
self.dump_response();
panic!("Key {query} not found.");
}
self
}
pub fn with_values<I, T>(self, query: &str, expect: I) -> Self
where
I: IntoIterator<Item = T>,

View File

@@ -837,6 +837,22 @@ impl<'x> DavQueryResult<'x> {
self
}
pub fn with_any_values(&self, expected_values: impl IntoIterator<Item = &'x str>) -> &Self {
let values = self
.values
.iter()
.map(|s| s.as_str())
.collect::<AHashSet<_>>();
let expected_values = AHashSet::from_iter(expected_values);
if values.is_disjoint(&expected_values) {
self.response.dump_response();
panic!("Expected at least one of {expected_values:?} values, but got {values:?}",);
}
self
}
pub fn without_values(&self, expected_values: impl IntoIterator<Item = &'x str>) -> &Self {
let expected_values = AHashSet::from_iter(expected_values);
let values = self