forked from ucan-wg/rs-ucan
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
62 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
use super::Selector; | ||
use super::Selector; // FIXME cycle? | ||
use super::{error::SelectorErrorReason, filter::Filter, Selectable, SelectorError}; | ||
use libipld_core::ipld::Ipld; | ||
use serde::{Deserialize, Serialize}; | ||
use std::cmp::Ordering; | ||
use std::fmt; | ||
use std::str::FromStr; | ||
|
@@ -199,35 +200,27 @@ mod tests { | |
use proptest::prelude::*; | ||
use testresult::TestResult; | ||
|
||
fn simple() -> Ipld { | ||
libipld::ipld!({ | ||
"foo": 42, | ||
"bar": "baz", | ||
"qux": true | ||
}) | ||
} | ||
|
||
fn email() -> Ipld { | ||
libipld::ipld!({ | ||
"from": "[email protected]", | ||
"to": ["[email protected]", "[email protected]"], | ||
"cc": ["[email protected]"], | ||
"subject": "Quarterly Reports", | ||
"body": "Here's Q2 the reports ..." | ||
}) | ||
} | ||
|
||
fn nested_data() -> Ipld { | ||
libipld::ipld!({ | ||
"name": "Alice", | ||
"age": 42, | ||
"friends": ["Bob", "Charlie"] | ||
}) | ||
} | ||
|
||
mod get { | ||
use super::*; | ||
|
||
fn nested_data() -> Ipld { | ||
Ipld::Map( | ||
vec![ | ||
("name".to_string(), Ipld::String("Alice".to_string())), | ||
("age".to_string(), Ipld::Integer(42)), | ||
( | ||
"friends".to_string(), | ||
Ipld::List(vec![ | ||
Ipld::String("Bob".to_string()), | ||
Ipld::String("Charlie".to_string()), | ||
]), | ||
), | ||
] | ||
.into_iter() | ||
.collect(), | ||
) | ||
} | ||
|
||
proptest! { | ||
#[test_log::test] | ||
fn test_identity(data: ipld::Newtype) { | ||
|
@@ -255,19 +248,13 @@ mod tests { | |
let selector: Select<Ipld> = Select::new(filters); | ||
|
||
let cleaned_data = match data.0.clone() { | ||
Ipld::Map(mut m) => m.remove("foo").map_or(Ipld::Null, |v| v), | ||
ipld => ipld, | ||
Ipld::Map(mut m) => { | ||
m.remove("foo").map_or(Ipld::Null, |v| v) | ||
} | ||
ipld => ipld | ||
}; | ||
prop_assert_eq!(selector.get(&cleaned_data)?, Ipld::Null); | ||
} | ||
} | ||
|
||
#[test_log::test] | ||
fn test_eq_dot_field_ending_try_null() -> TestResult { | ||
let s = Select::from_str(".from.not?")?; | ||
|
||
pretty::assert_eq!(s.get(&email()), Ok(Ipld::Null)); | ||
Ok(()) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters