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;
|
use serde_json::Value;
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
pub enum SelectorPart {
|
pub enum SelectorPart {
|
||||||
Field(String),
|
Field(String),
|
||||||
Index(usize),
|
Index(usize),
|
||||||
|
@ -1,4 +1,27 @@
|
|||||||
|
use super::*;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn should_fail() {
|
fn basic_find() {
|
||||||
assert_eq!(true, false);
|
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 json_find;
|
||||||
mod validator;
|
mod validator;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug, PartialEq, Eq)]
|
||||||
struct Error {
|
struct Error {
|
||||||
kind: ErrorKind,
|
kind: ErrorKind,
|
||||||
id: Id,
|
id: Id,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug, PartialEq, Eq)]
|
||||||
enum ErrorKind {
|
enum ErrorKind {
|
||||||
NotFound,
|
NotFound,
|
||||||
Custom(String),
|
Custom(String),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user