Skip to content

Commit 96126c2

Browse files
author
Tony Worm
committed
hof/flow: add testscript for patch fix
1 parent b3d223a commit 96126c2

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
exec hof flow patch.cue
2+
cmp stdout stdout.golden
3+
4+
-- stdout.golden --
5+
P.next: {
6+
b: "b"
7+
e: {
8+
a: "a"
9+
b: "b"
10+
c: "c"
11+
}
12+
f: "new"
13+
}
14+
15+
-- patch.cue --
16+
package patch
17+
18+
// original thing being patched
19+
o: {
20+
a: "a"
21+
b: "b"
22+
e: {
23+
a: "a"
24+
b: "b"
25+
d: "d"
26+
}
27+
}
28+
29+
// update structure
30+
p: {
31+
"-": {
32+
a: "a" // remove field 'a'
33+
}
34+
e: {
35+
"-": {
36+
d: "d" // remove nested field 'd'
37+
}
38+
"+": {
39+
c: "c" // add new nested field 'c'
40+
}
41+
}
42+
"+": {
43+
f: "new" // add new field 'f'
44+
}
45+
}
46+
47+
@flow()
48+
P: {
49+
@task(st.Patch)
50+
orig: o
51+
patch: p
52+
next: _
53+
} @print(next)
54+
55+
// Result after patch
56+
n: {
57+
b: "b"
58+
e: {
59+
a: "a"
60+
b: "b"
61+
c: "c"
62+
}
63+
f: "new"
64+
}
65+
66+
// validation
67+
n: P.next

0 commit comments

Comments
 (0)