Enable setting record keys values when record is NONE
This commit is contained in:
parent
5e0e144acb
commit
9e50db40d8
1 changed files with 40 additions and 0 deletions
|
@ -66,6 +66,16 @@ impl Value {
|
|||
}
|
||||
_ => Ok(()),
|
||||
},
|
||||
// Current path part is empty
|
||||
Value::Null => {
|
||||
*self = Value::base();
|
||||
self.set(ctx, opt, exe, path, val).await
|
||||
}
|
||||
// Current path part is empty
|
||||
Value::None => {
|
||||
*self = Value::base();
|
||||
self.set(ctx, opt, exe, path, val).await
|
||||
}
|
||||
// Ignore everything else
|
||||
_ => Ok(()),
|
||||
},
|
||||
|
@ -95,6 +105,26 @@ mod tests {
|
|||
assert_eq!(res, val);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn set_empty() {
|
||||
let (ctx, opt, exe) = mock();
|
||||
let idi = Idiom::parse("test");
|
||||
let mut val = Value::None;
|
||||
let res = Value::parse("{ test: 999 }");
|
||||
val.set(&ctx, &opt, &exe, &idi, Value::from(999)).await.unwrap();
|
||||
assert_eq!(res, val);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn set_blank() {
|
||||
let (ctx, opt, exe) = mock();
|
||||
let idi = Idiom::parse("test.something");
|
||||
let mut val = Value::None;
|
||||
let res = Value::parse("{ test: { something: 999 } }");
|
||||
val.set(&ctx, &opt, &exe, &idi, Value::from(999)).await.unwrap();
|
||||
assert_eq!(res, val);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn set_reset() {
|
||||
let (ctx, opt, exe) = mock();
|
||||
|
@ -115,6 +145,16 @@ mod tests {
|
|||
assert_eq!(res, val);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn set_allow() {
|
||||
let (ctx, opt, exe) = mock();
|
||||
let idi = Idiom::parse("test.something.allow");
|
||||
let mut val = Value::parse("{ test: { other: null } }");
|
||||
let res = Value::parse("{ test: { other: null, something: { allow: 999 } } }");
|
||||
val.set(&ctx, &opt, &exe, &idi, Value::from(999)).await.unwrap();
|
||||
assert_eq!(res, val);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn set_wrong() {
|
||||
let (ctx, opt, exe) = mock();
|
||||
|
|
Loading…
Reference in a new issue