Skip to content

Commit 98ca6e3

Browse files
committed
encoding/gocode: fix test
As part of previous CL, I noticed that the expected validation didn't seem to be happening. It turned out that this was due to a mismatch in field names between Go type and CUE code. It would probably be better to use a definition here for typo-checking, but in the meantime, change the tests so they're actually checking what they intend to be checking. Signed-off-by: Roger Peppe <[email protected]> Change-Id: I63d93f8ed81b29b3ed92bc728bc48f55a90e39ab Reviewed-on: https://cue.gerrithub.io/c/cue-lang/cue/+/1231503 TryBot-Result: CUEcueckoo <[email protected]> Reviewed-by: Marcel van Lohuizen <[email protected]>
1 parent b3d9ffc commit 98ca6e3

File tree

4 files changed

+20
-7
lines changed

4 files changed

+20
-7
lines changed

encoding/gocode/gen_test.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,24 @@ O: conflicting values {A:"X",P:4} and null (mismatched types struct and null):
8181
O.P: invalid value 4 (out of bound >5):
8282
pkg2/instance.cue:x:x`,
8383
}, {
84+
name: "fail nested struct of transitively imported package",
85+
value: &pkg1.MyStruct{
86+
A: 5,
87+
B: "dog",
88+
I: &pkg2.ImportMe{A: 1000, B: "z"},
89+
},
90+
want: `4 errors in empty disjunction:
91+
conflicting values {A:5,B:"dog",T:"0001-01-01T00:00:00Z",I:{a:1000,b:"z"}} and null (mismatched types struct and null)
92+
I: 2 errors in empty disjunction:
93+
I: conflicting values {a:1000,b:"z"} and null (mismatched types struct and null):
94+
pkg1/instance.cue:x:x
95+
I.a: invalid value 1000 (out of bound <100):
96+
pkg2/instance.cue:x:x`}, {
8497
name: "all good",
8598
value: &pkg1.MyStruct{
8699
A: 5,
87100
B: "dog",
88-
I: &pkg2.ImportMe{A: 1000, B: "a"},
101+
I: &pkg2.ImportMe{A: 50, B: "a"},
89102
},
90103
want: `nil`,
91104
}}

encoding/gocode/testdata/pkg1/cue_gen.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

encoding/gocode/testdata/pkg2/cue_gen.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

encoding/gocode/testdata/pkg2/instance.cue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ package pkg2
33
import "strings"
44

55
ImportMe: {
6-
A: <100
7-
B: strings.ContainsAny("abc")
6+
a: <100
7+
b: strings.ContainsAny("abc")
88
}
99

1010
PickMe: >5

0 commit comments

Comments
 (0)