Merge pull request #65 from blocklayerhq/fix-value-json
Fix bug in Value.JSON(), with regression test
This commit is contained in:
commit
2ee27e83f3
@ -186,6 +186,7 @@ func (v *Value) JSON() JSON {
|
|||||||
},
|
},
|
||||||
nil,
|
nil,
|
||||||
)
|
)
|
||||||
|
out, _ = out.Get(cuePathToStrings(v.Path())...)
|
||||||
return out
|
return out
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,6 +12,23 @@ func TestSimple(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestJSON(t *testing.T) {
|
||||||
|
cc := &Compiler{}
|
||||||
|
v, err := cc.Compile("", `foo: hello: "world"`)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
b1 := v.JSON()
|
||||||
|
if string(b1) != `{"foo":{"hello":"world"}}` {
|
||||||
|
t.Fatal(b1)
|
||||||
|
}
|
||||||
|
// Reproduce a bug where Value.Get().JSON() ignores Get()
|
||||||
|
b2 := v.Get("foo").JSON()
|
||||||
|
if string(b2) != `{"hello":"world"}` {
|
||||||
|
t.Fatal(b2)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestCompileBootScript(t *testing.T) {
|
func TestCompileBootScript(t *testing.T) {
|
||||||
cc := &Compiler{}
|
cc := &Compiler{}
|
||||||
cfg, err := cc.Compile("boot.cue", defaultBootScript)
|
cfg, err := cc.Compile("boot.cue", defaultBootScript)
|
||||||
|
Reference in New Issue
Block a user