fc45ff09a3
* Allow change to return value from users closure * Add closure_result field to OptimisticChangeResult
42 lines
1.2 KiB
Rust
42 lines
1.2 KiB
Rust
use automerge_frontend::{Frontend, InvalidChangeRequest, LocalChange, Path, Value};
|
|
|
|
#[test]
|
|
fn test_delete_index_in_mutation() {
|
|
let mut frontend = Frontend::new();
|
|
let _cr = frontend
|
|
.change::<_, _, InvalidChangeRequest>(None, |doc| {
|
|
doc.add_change(LocalChange::set(
|
|
Path::root().key("vals"),
|
|
Value::Sequence(Vec::new()),
|
|
))?;
|
|
Ok(())
|
|
})
|
|
.unwrap();
|
|
|
|
frontend
|
|
.change::<_, _, InvalidChangeRequest>(None, |doc| {
|
|
doc.add_change(LocalChange::insert(
|
|
Path::root().key("vals").index(0),
|
|
"0".into(),
|
|
))?;
|
|
Ok(())
|
|
})
|
|
.unwrap();
|
|
|
|
frontend
|
|
.change::<_, _, InvalidChangeRequest>(None, |doc| {
|
|
doc.add_change(LocalChange::insert(
|
|
Path::root().key("vals").index(1),
|
|
"1".into(),
|
|
))?;
|
|
Ok(())
|
|
})
|
|
.unwrap();
|
|
|
|
frontend
|
|
.change::<_, _, InvalidChangeRequest>(None, |doc| {
|
|
doc.add_change(LocalChange::delete(Path::root().key("vals").index(1)))?;
|
|
Ok(())
|
|
})
|
|
.unwrap();
|
|
}
|