From 341c1cb1bbaa7e70b6aaf13edb375274022cd924 Mon Sep 17 00:00:00 2001 From: Michael Cuffaro Date: Mon, 5 Feb 2024 15:05:38 -0500 Subject: [PATCH] redo changes that git failed to merge --- src/api_test.rs | 21 --------------------- test/expected/history.tsv | 28 ++++++++++++++-------------- 2 files changed, 14 insertions(+), 35 deletions(-) diff --git a/src/api_test.rs b/src/api_test.rs index ae4e71d8..e551a1da 100644 --- a/src/api_test.rs +++ b/src/api_test.rs @@ -409,9 +409,6 @@ async fn test_undo_redo(valve: &Valve) -> Result<(), ValveError> { "numeric_foreign_column": {"messages": [], "valid": true, "value": "11"}, }); - // Our initial undo/redo state: - verify_undo_redo(pool, false, false).await?; - // Undo/redo test 1: let (_rn, _r) = valve .insert_row("table10", &row_1.as_object().unwrap()) @@ -423,8 +420,6 @@ async fn test_undo_redo(valve: &Valve) -> Result<(), ValveError> { valve.undo().await?; - verify_undo_redo(pool, false, true).await?; - // Undo/redo test 2: valve .update_row("table10", &8, &row_2.as_object().unwrap()) @@ -436,8 +431,6 @@ async fn test_undo_redo(valve: &Valve) -> Result<(), ValveError> { valve.undo().await?; - verify_undo_redo(pool, false, true).await?; - // Undo/redo test 3: valve.delete_row("table10", &8).await?; @@ -447,8 +440,6 @@ async fn test_undo_redo(valve: &Valve) -> Result<(), ValveError> { valve.undo().await?; - verify_undo_redo(pool, false, true).await?; - // Undo/redo test 4: let (rn, _row) = valve .insert_row("table10", &row_1.as_object().unwrap()) @@ -458,35 +449,23 @@ async fn test_undo_redo(valve: &Valve) -> Result<(), ValveError> { .update_row("table10", &rn, &row_2.as_object().unwrap()) .await?; - verify_undo_redo(pool, true, false).await?; - // Undo update: valve.undo().await?; - verify_undo_redo(pool, true, true).await?; - // Redo update: valve.redo().await?; valve.delete_row("table10", &rn).await?; - verify_undo_redo(pool, true, false).await?; - // Undo delete: valve.undo().await?; - verify_undo_redo(pool, true, true).await?; - // Undo update: valve.undo().await?; - verify_undo_redo(pool, true, true).await?; - // Undo insert: valve.undo().await?; - verify_undo_redo(pool, false, true).await?; - eprintln!("done."); Ok(()) } diff --git a/test/expected/history.tsv b/test/expected/history.tsv index 86afe795..23f15d77 100644 --- a/test/expected/history.tsv +++ b/test/expected/history.tsv @@ -1,15 +1,15 @@ history_id table row from to summary user undone_by -1 table10 9 {"foreign_column":{"messages":[],"valid":true,"value":"j"},"numeric_foreign_column":{"messages":[],"valid":true,"value":"10"},"other_foreign_column":{"messages":[],"valid":true,"value":"j"}} VALVE VALVE -2 table10 8 {"foreign_column":{"messages":[],"valid":true,"value":"h"},"numeric_foreign_column":{"messages":[],"valid":true,"value":"8"},"other_foreign_column":{"messages":[],"valid":true,"value":"h"}} {"foreign_column":{"messages":[],"valid":true,"value":"k"},"numeric_foreign_column":{"messages":[],"valid":true,"value":"11"},"other_foreign_column":{"messages":[],"valid":true,"value":"k"}} [{"column":"foreign_column","level":"update","message":"Value changed from 'h' to 'k'","old_value":"h","value":"k"},{"column":"numeric_foreign_column","level":"update","message":"Value changed from 8 to 11","old_value":"8","value":"11"},{"column":"other_foreign_column","level":"update","message":"Value changed from 'h' to 'k'","old_value":"h","value":"k"}] VALVE VALVE -3 table10 8 {"foreign_column":{"messages":[],"valid":true,"value":"h"},"numeric_foreign_column":{"messages":[],"valid":true,"value":"8"},"other_foreign_column":{"messages":[],"valid":true,"value":"h"}} VALVE VALVE -4 table10 10 {"foreign_column":{"messages":[],"valid":true,"value":"j"},"numeric_foreign_column":{"messages":[],"valid":true,"value":"10"},"other_foreign_column":{"messages":[],"valid":true,"value":"j"}} VALVE VALVE -5 table10 10 {"foreign_column":{"messages":[],"valid":true,"value":"j"},"numeric_foreign_column":{"messages":[],"valid":true,"value":"10"},"other_foreign_column":{"messages":[],"valid":true,"value":"j"}} {"foreign_column":{"messages":[],"valid":true,"value":"k"},"numeric_foreign_column":{"messages":[],"valid":true,"value":"11"},"other_foreign_column":{"messages":[],"valid":true,"value":"k"}} [{"column":"foreign_column","level":"update","message":"Value changed from 'j' to 'k'","old_value":"j","value":"k"},{"column":"numeric_foreign_column","level":"update","message":"Value changed from 10 to 11","old_value":"10","value":"11"},{"column":"other_foreign_column","level":"update","message":"Value changed from 'j' to 'k'","old_value":"j","value":"k"}] VALVE VALVE -6 table10 10 {"foreign_column":{"messages":[],"valid":true,"value":"k"},"numeric_foreign_column":{"messages":[],"valid":true,"value":"11"},"other_foreign_column":{"messages":[],"valid":true,"value":"k"}} VALVE VALVE -7 table2 1 {"bar":{"messages":[],"valid":true,"value":""},"child":{"messages":[],"valid":true,"value":"a"},"foo":{"messages":[{"column":"foo","level":"error","message":"bar cannot be null if foo is not null","rule":"rule:foo-2","value":"5"},{"column":"foo","level":"error","message":"bar must be 'y' or 'z' if foo = 5","rule":"rule:foo-4","value":"5"}],"valid":false,"value":"5"},"parent":{"messages":[],"valid":true,"value":"b"},"xyzzy":{"messages":[],"valid":true,"value":"d"}} {"bar":{"messages":[{"level":"error","message":"An unrelated error","rule":"custom:unrelated"}],"valid":false,"value":"B"},"child":{"messages":[{"level":"error","message":"Values of child must be unique","rule":"tree:child-unique"}],"valid":false,"value":"b"},"foo":{"messages":[],"valid":true,"value":"1"},"parent":{"messages":[],"valid":true,"value":"f"},"xyzzy":{"messages":[{"level":"error","message":"Value 'w' of column xyzzy is not in table2.child","rule":"under:not-in-tree"}],"valid":false,"value":"w"}} [{"column":"bar","level":"update","message":"Value changed from '' to 'B'","old_value":"","value":"B"},{"column":"child","level":"update","message":"Value changed from 'a' to 'b'","old_value":"a","value":"b"},{"column":"foo","level":"update","message":"Value changed from 5 to 1","old_value":"5","value":"1"},{"column":"parent","level":"update","message":"Value changed from 'b' to 'f'","old_value":"b","value":"f"},{"column":"xyzzy","level":"update","message":"Value changed from 'd' to 'w'","old_value":"d","value":"w"}] VALVE -8 table3 11 {"id":{"messages":[],"valid":true,"value":"BFO:0000027"},"label":{"messages":[],"valid":true,"value":"bazaar"},"parent":{"messages":[{"level":"error","message":"An unrelated error","rule":"custom:unrelated"},{"level":"error","message":"Value 'barrie' of column parent is not in column label","rule":"tree:foreign"}],"valid":false,"value":"barrie"},"source":{"messages":[{"level":"error","message":"Value 'BFOBBER' of column source is not in table1.prefix","rule":"key:foreign"}],"valid":false,"value":"BFOBBER"},"type":{"messages":[],"valid":true,"value":"owl:Class"}} VALVE -9 table6 1 {"bar":{"messages":[],"valid":true,"value":""},"child":{"messages":[],"valid":true,"value":"1"},"foo":{"messages":[{"column":"foo","level":"error","message":"bar cannot be null if foo is not null","rule":"rule:foo-2","value":"e"},{"column":"foo","level":"error","message":"bar must be 25 or 26 if foo = 'e'","rule":"rule:foo-4","value":"e"}],"valid":false,"value":"e"},"parent":{"messages":[],"valid":true,"value":"2"},"xyzzy":{"messages":[],"valid":true,"value":"4"}} {"bar":{"messages":[{"level":"error","message":"An unrelated error","rule":"custom:unrelated"}],"valid":false,"value":"2"},"child":{"messages":[{"level":"error","message":"Values of child must be unique","rule":"tree:child-unique"}],"valid":false,"value":"2"},"foo":{"messages":[],"valid":true,"value":"a"},"parent":{"messages":[],"valid":true,"value":"6"},"xyzzy":{"messages":[{"level":"error","message":"Value '23' of column xyzzy is not in table6.child","rule":"under:not-in-tree"}],"valid":false,"value":"23"}} [{"column":"bar","level":"update","message":"Value changed from '' to 2","old_value":"","value":"2"},{"column":"child","level":"update","message":"Value changed from 1 to 2","old_value":"1","value":"2"},{"column":"foo","level":"update","message":"Value changed from 'e' to 'a'","old_value":"e","value":"a"},{"column":"parent","level":"update","message":"Value changed from 2 to 6","old_value":"2","value":"6"},{"column":"xyzzy","level":"update","message":"Value changed from 4 to 23","old_value":"4","value":"23"}] VALVE -10 table6 10 {"bar":{"messages":[{"level":"error","message":"An unrelated error","rule":"custom:unrelated"}],"valid":false,"value":"2"},"child":{"messages":[{"level":"error","message":"Values of child must be unique","rule":"tree:child-unique"}],"valid":false,"value":"2"},"foo":{"messages":[],"valid":true,"value":"a"},"parent":{"messages":[],"valid":true,"value":"6"},"xyzzy":{"messages":[{"level":"error","message":"Value '23' of column xyzzy is not in table6.child","rule":"under:not-in-tree"}],"valid":false,"value":"23"}} VALVE -11 table10 1 {"foreign_column":{"messages":[],"valid":true,"value":"a"},"numeric_foreign_column":{"messages":[],"valid":true,"value":"1"},"other_foreign_column":{"messages":[],"valid":true,"value":"a"}} {"foreign_column":{"messages":[],"valid":true,"value":"w"},"numeric_foreign_column":{"messages":[{"level":"error","message":"numeric_foreign_column should be a positive or negative integer","rule":"datatype:integer"},{"level":"error","message":"numeric_foreign_column should be a line of text that does not begin or end with whitespace","rule":"datatype:trimmed_line"}],"valid":false,"value":""},"other_foreign_column":{"messages":[],"valid":true,"value":"z"}} [{"column":"foreign_column","level":"update","message":"Value changed from 'a' to 'w'","old_value":"a","value":"w"},{"column":"numeric_foreign_column","level":"update","message":"Value changed from 1 to ''","old_value":"1","value":""},{"column":"other_foreign_column","level":"update","message":"Value changed from 'a' to 'z'","old_value":"a","value":"z"}] VALVE -12 table11 2 {"bar":{"messages":[],"valid":true,"value":"f"},"child":{"messages":[],"valid":true,"value":"b"},"foo":{"messages":[],"valid":true,"value":"e"},"parent":{"messages":[],"valid":true,"value":"c"},"xyzzy":{"messages":[],"valid":true,"value":"d"}} {"bar":{"messages":[],"valid":true,"value":"f"},"child":{"messages":[],"valid":true,"value":"b"},"foo":{"messages":[{"level":"error","message":"Values of foo must be unique","rule":"key:primary"}],"valid":false,"value":"d"},"parent":{"messages":[],"valid":true,"value":"c"},"xyzzy":{"messages":[],"valid":true,"value":"d"}} [{"column":"foo","level":"update","message":"Value changed from 'e' to 'd'","old_value":"e","value":"d"}] VALVE -13 table11 4 {"bar":{"messages":[],"valid":true,"value":"z"},"child":{"messages":[],"valid":true,"value":"f"},"foo":{"messages":[],"valid":true,"value":"e"},"parent":{"messages":[],"valid":true,"value":"g"},"xyzzy":{"messages":[],"valid":true,"value":"x"}} VALVE -14 table10 11 {"foreign_column":{"messages":[],"valid":true,"value":"i"},"numeric_foreign_column":{"messages":[],"valid":true,"value":"9"},"other_foreign_column":{"messages":[],"valid":true,"value":"i"}} VALVE +1 table2 1 {"bar":{"messages":[],"valid":true,"value":""},"child":{"messages":[],"valid":true,"value":"a"},"foo":{"messages":[{"column":"foo","level":"error","message":"bar cannot be null if foo is not null","rule":"rule:foo-2","value":"5"},{"column":"foo","level":"error","message":"bar must be 'y' or 'z' if foo = 5","rule":"rule:foo-4","value":"5"}],"valid":false,"value":"5"},"parent":{"messages":[],"valid":true,"value":"b"},"xyzzy":{"messages":[],"valid":true,"value":"d"}} {"bar":{"messages":[{"level":"error","message":"An unrelated error","rule":"custom:unrelated"}],"valid":false,"value":"B"},"child":{"messages":[{"level":"error","message":"Values of child must be unique","rule":"tree:child-unique"}],"valid":false,"value":"b"},"foo":{"messages":[],"valid":true,"value":"1"},"parent":{"messages":[],"valid":true,"value":"f"},"xyzzy":{"messages":[{"level":"error","message":"Value 'w' of column xyzzy is not in table2.child","rule":"under:not-in-tree"}],"valid":false,"value":"w"}} [{"column":"bar","level":"update","message":"Value changed from '' to 'B'","old_value":"","value":"B"},{"column":"child","level":"update","message":"Value changed from 'a' to 'b'","old_value":"a","value":"b"},{"column":"foo","level":"update","message":"Value changed from 5 to 1","old_value":"5","value":"1"},{"column":"parent","level":"update","message":"Value changed from 'b' to 'f'","old_value":"b","value":"f"},{"column":"xyzzy","level":"update","message":"Value changed from 'd' to 'w'","old_value":"d","value":"w"}] VALVE +2 table3 11 {"id":{"messages":[],"valid":true,"value":"BFO:0000027"},"label":{"messages":[],"valid":true,"value":"bazaar"},"parent":{"messages":[{"level":"error","message":"An unrelated error","rule":"custom:unrelated"},{"level":"error","message":"Value 'barrie' of column parent is not in column label","rule":"tree:foreign"}],"valid":false,"value":"barrie"},"source":{"messages":[{"level":"error","message":"Value 'BFOBBER' of column source is not in table1.prefix","rule":"key:foreign"}],"valid":false,"value":"BFOBBER"},"type":{"messages":[],"valid":true,"value":"owl:Class"}} VALVE +3 table6 1 {"bar":{"messages":[],"valid":true,"value":""},"child":{"messages":[],"valid":true,"value":"1"},"foo":{"messages":[{"column":"foo","level":"error","message":"bar cannot be null if foo is not null","rule":"rule:foo-2","value":"e"},{"column":"foo","level":"error","message":"bar must be 25 or 26 if foo = 'e'","rule":"rule:foo-4","value":"e"}],"valid":false,"value":"e"},"parent":{"messages":[],"valid":true,"value":"2"},"xyzzy":{"messages":[],"valid":true,"value":"4"}} {"bar":{"messages":[{"level":"error","message":"An unrelated error","rule":"custom:unrelated"}],"valid":false,"value":"2"},"child":{"messages":[{"level":"error","message":"Values of child must be unique","rule":"tree:child-unique"}],"valid":false,"value":"2"},"foo":{"messages":[],"valid":true,"value":"a"},"parent":{"messages":[],"valid":true,"value":"6"},"xyzzy":{"messages":[{"level":"error","message":"Value '23' of column xyzzy is not in table6.child","rule":"under:not-in-tree"}],"valid":false,"value":"23"}} [{"column":"bar","level":"update","message":"Value changed from '' to 2","old_value":"","value":"2"},{"column":"child","level":"update","message":"Value changed from 1 to 2","old_value":"1","value":"2"},{"column":"foo","level":"update","message":"Value changed from 'e' to 'a'","old_value":"e","value":"a"},{"column":"parent","level":"update","message":"Value changed from 2 to 6","old_value":"2","value":"6"},{"column":"xyzzy","level":"update","message":"Value changed from 4 to 23","old_value":"4","value":"23"}] VALVE +4 table6 10 {"bar":{"messages":[{"level":"error","message":"An unrelated error","rule":"custom:unrelated"}],"valid":false,"value":"2"},"child":{"messages":[{"level":"error","message":"Values of child must be unique","rule":"tree:child-unique"}],"valid":false,"value":"2"},"foo":{"messages":[],"valid":true,"value":"a"},"parent":{"messages":[],"valid":true,"value":"6"},"xyzzy":{"messages":[{"level":"error","message":"Value '23' of column xyzzy is not in table6.child","rule":"under:not-in-tree"}],"valid":false,"value":"23"}} VALVE +5 table10 1 {"foreign_column":{"messages":[],"valid":true,"value":"a"},"numeric_foreign_column":{"messages":[],"valid":true,"value":"1"},"other_foreign_column":{"messages":[],"valid":true,"value":"a"}} {"foreign_column":{"messages":[],"valid":true,"value":"w"},"numeric_foreign_column":{"messages":[{"level":"error","message":"numeric_foreign_column should be a positive or negative integer","rule":"datatype:integer"},{"level":"error","message":"numeric_foreign_column should be a line of text that does not begin or end with whitespace","rule":"datatype:trimmed_line"}],"valid":false,"value":""},"other_foreign_column":{"messages":[],"valid":true,"value":"z"}} [{"column":"foreign_column","level":"update","message":"Value changed from 'a' to 'w'","old_value":"a","value":"w"},{"column":"numeric_foreign_column","level":"update","message":"Value changed from 1 to ''","old_value":"1","value":""},{"column":"other_foreign_column","level":"update","message":"Value changed from 'a' to 'z'","old_value":"a","value":"z"}] VALVE +6 table11 2 {"bar":{"messages":[],"valid":true,"value":"f"},"child":{"messages":[],"valid":true,"value":"b"},"foo":{"messages":[],"valid":true,"value":"e"},"parent":{"messages":[],"valid":true,"value":"c"},"xyzzy":{"messages":[],"valid":true,"value":"d"}} {"bar":{"messages":[],"valid":true,"value":"f"},"child":{"messages":[],"valid":true,"value":"b"},"foo":{"messages":[{"level":"error","message":"Values of foo must be unique","rule":"key:primary"}],"valid":false,"value":"d"},"parent":{"messages":[],"valid":true,"value":"c"},"xyzzy":{"messages":[],"valid":true,"value":"d"}} [{"column":"foo","level":"update","message":"Value changed from 'e' to 'd'","old_value":"e","value":"d"}] VALVE +7 table11 4 {"bar":{"messages":[],"valid":true,"value":"z"},"child":{"messages":[],"valid":true,"value":"f"},"foo":{"messages":[],"valid":true,"value":"e"},"parent":{"messages":[],"valid":true,"value":"g"},"xyzzy":{"messages":[],"valid":true,"value":"x"}} VALVE +8 table10 9 {"foreign_column":{"messages":[],"valid":true,"value":"i"},"numeric_foreign_column":{"messages":[],"valid":true,"value":"9"},"other_foreign_column":{"messages":[],"valid":true,"value":"i"}} VALVE +9 table10 10 {"foreign_column":{"messages":[],"valid":true,"value":"j"},"numeric_foreign_column":{"messages":[],"valid":true,"value":"10"},"other_foreign_column":{"messages":[],"valid":true,"value":"j"}} VALVE VALVE +10 table10 8 {"foreign_column":{"messages":[],"valid":true,"value":"h"},"numeric_foreign_column":{"messages":[],"valid":true,"value":"8"},"other_foreign_column":{"messages":[],"valid":true,"value":"h"}} {"foreign_column":{"messages":[],"valid":true,"value":"k"},"numeric_foreign_column":{"messages":[],"valid":true,"value":"11"},"other_foreign_column":{"messages":[],"valid":true,"value":"k"}} [{"column":"foreign_column","level":"update","message":"Value changed from 'h' to 'k'","old_value":"h","value":"k"},{"column":"numeric_foreign_column","level":"update","message":"Value changed from 8 to 11","old_value":"8","value":"11"},{"column":"other_foreign_column","level":"update","message":"Value changed from 'h' to 'k'","old_value":"h","value":"k"}] VALVE VALVE +11 table10 8 {"foreign_column":{"messages":[],"valid":true,"value":"h"},"numeric_foreign_column":{"messages":[],"valid":true,"value":"8"},"other_foreign_column":{"messages":[],"valid":true,"value":"h"}} VALVE VALVE +12 table10 11 {"foreign_column":{"messages":[],"valid":true,"value":"j"},"numeric_foreign_column":{"messages":[],"valid":true,"value":"10"},"other_foreign_column":{"messages":[],"valid":true,"value":"j"}} VALVE VALVE +13 table10 11 {"foreign_column":{"messages":[],"valid":true,"value":"j"},"numeric_foreign_column":{"messages":[],"valid":true,"value":"10"},"other_foreign_column":{"messages":[],"valid":true,"value":"j"}} {"foreign_column":{"messages":[],"valid":true,"value":"k"},"numeric_foreign_column":{"messages":[],"valid":true,"value":"11"},"other_foreign_column":{"messages":[],"valid":true,"value":"k"}} [{"column":"foreign_column","level":"update","message":"Value changed from 'j' to 'k'","old_value":"j","value":"k"},{"column":"numeric_foreign_column","level":"update","message":"Value changed from 10 to 11","old_value":"10","value":"11"},{"column":"other_foreign_column","level":"update","message":"Value changed from 'j' to 'k'","old_value":"j","value":"k"}] VALVE VALVE +14 table10 11 {"foreign_column":{"messages":[],"valid":true,"value":"k"},"numeric_foreign_column":{"messages":[],"valid":true,"value":"11"},"other_foreign_column":{"messages":[],"valid":true,"value":"k"}} VALVE VALVE