From 96126c251a61a47c8f94b99a3286ad7cfed6bf1f Mon Sep 17 00:00:00 2001 From: Tony Worm Date: Fri, 27 Dec 2024 23:12:51 -0500 Subject: [PATCH] hof/flow: add testscript for patch fix --- .../tasks/st/issue_402_patch_arg_order.txt | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 flow/testdata/tasks/st/issue_402_patch_arg_order.txt diff --git a/flow/testdata/tasks/st/issue_402_patch_arg_order.txt b/flow/testdata/tasks/st/issue_402_patch_arg_order.txt new file mode 100644 index 000000000..dee0a6625 --- /dev/null +++ b/flow/testdata/tasks/st/issue_402_patch_arg_order.txt @@ -0,0 +1,67 @@ +exec hof flow patch.cue +cmp stdout stdout.golden + +-- stdout.golden -- +P.next: { + b: "b" + e: { + a: "a" + b: "b" + c: "c" + } + f: "new" +} + +-- patch.cue -- +package patch + +// original thing being patched +o: { + a: "a" + b: "b" + e: { + a: "a" + b: "b" + d: "d" + } +} + +// update structure +p: { + "-": { + a: "a" // remove field 'a' + } + e: { + "-": { + d: "d" // remove nested field 'd' + } + "+": { + c: "c" // add new nested field 'c' + } + } + "+": { + f: "new" // add new field 'f' + } +} + +@flow() +P: { + @task(st.Patch) + orig: o + patch: p + next: _ +} @print(next) + +// Result after patch +n: { + b: "b" + e: { + a: "a" + b: "b" + c: "c" + } + f: "new" +} + +// validation +n: P.next \ No newline at end of file