Add a test that makes sense
This commit is contained in:
parent
4b2a1eb775
commit
09818a8cca
@ -2,7 +2,7 @@ use std::fmt::Write;
|
||||
|
||||
use serde_json::Value;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub enum SelectorPart {
|
||||
Field(String),
|
||||
Index(usize),
|
||||
|
@ -1,4 +1,27 @@
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn should_fail() {
|
||||
assert_eq!(true, false);
|
||||
fn basic_find() {
|
||||
use SelectorPart::*;
|
||||
|
||||
let j = serde_json::json!({
|
||||
"index": {
|
||||
"4": {
|
||||
"inner": {
|
||||
"items": ["1", "2", "3"]
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
let sel = find_selector(&j, &serde_json::json!("1"));
|
||||
let exp: Vec<Vec<SelectorPart>> = vec![vec![
|
||||
Field("index".to_owned()),
|
||||
Field("4".to_owned()),
|
||||
Field("inner".to_owned()),
|
||||
Field("items".to_owned()),
|
||||
Index(0),
|
||||
]];
|
||||
|
||||
assert_eq!(exp, sel);
|
||||
}
|
||||
|
@ -9,13 +9,13 @@ pub(crate) mod item_kind;
|
||||
mod json_find;
|
||||
mod validator;
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
struct Error {
|
||||
kind: ErrorKind,
|
||||
id: Id,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
enum ErrorKind {
|
||||
NotFound,
|
||||
Custom(String),
|
||||
|
Loading…
x
Reference in New Issue
Block a user