Add a test that makes sense

This commit is contained in:
Nixon Enraght-Moony 2022-11-26 16:24:43 +00:00
parent 4b2a1eb775
commit 09818a8cca
3 changed files with 28 additions and 5 deletions

View File

@ -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),

View File

@ -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);
}

View File

@ -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),