mirror of
https://github.com/MontFerret/ferret.git
synced 2025-12-03 22:24:14 +02:00
Added params check before execution
This commit is contained in:
@@ -111,6 +111,37 @@ func TestParam(t *testing.T) {
|
||||
)
|
||||
|
||||
So(string(out), ShouldEqual, `"baz"`)
|
||||
})
|
||||
|
||||
Convey("Should return an error if param values are not passed", t, func() {
|
||||
prog := compiler.New().
|
||||
MustCompile(`
|
||||
LET doc = { foo: { bar: "baz" } }
|
||||
|
||||
RETURN doc.@attr.@subattr
|
||||
`)
|
||||
|
||||
_, err := prog.Run(
|
||||
context.Background(),
|
||||
)
|
||||
|
||||
So(err, ShouldNotBeNil)
|
||||
So(err.Error(), ShouldEqual, runtime.ErrMissedParams.Error())
|
||||
})
|
||||
Convey("Should be possible to use in member expression as segments", t, func() {
|
||||
prog := compiler.New().
|
||||
MustCompile(`
|
||||
LET doc = { foo: { bar: "baz" } }
|
||||
|
||||
RETURN doc.@attr.@subattr
|
||||
`)
|
||||
|
||||
_, err := prog.Run(
|
||||
context.Background(),
|
||||
runtime.WithParam("attr", "foo"),
|
||||
)
|
||||
|
||||
So(err, ShouldNotBeNil)
|
||||
So(err.Error(), ShouldContainSubstring, "subattr")
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user