1
0
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:
Tim Voronov
2019-10-11 17:31:23 -04:00
parent 09a7c584eb
commit 9e7998f9c8
6 changed files with 113 additions and 41 deletions

View File

@@ -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")
})
}