mirror of
https://github.com/MontFerret/ferret.git
synced 2025-12-05 22:26:09 +02:00
Next (#214)
* Renamed DOCUMENT to PAGE * Added PageLoadParams * Added PageLoadParams * Renamed LoadPageParams -> PageLoadParams * Added support for context.Done() (#201) * Bug/#189 operators precedence (#202) * Fixed math operators precedence * Fixed logical operators precedence * Fixed array operator * Added support for parentheses to enforce a different operator evaluation order * Feature/#200 drivers (#209) * Added new interfaces * Renamed dynamic to cdp driver * Renamed drivers * Added ELEMENT_EXISTS function (#210) * Renamed back PAGE to DOCUMENT (#211) * Added Getter and Setter interfaces
This commit is contained in:
@@ -8,6 +8,11 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
type Result struct {
|
||||
Value []byte
|
||||
Error error
|
||||
}
|
||||
|
||||
func TestProgram(t *testing.T) {
|
||||
Convey("Should recover from panic", t, func() {
|
||||
c := compiler.New()
|
||||
@@ -22,4 +27,28 @@ func TestProgram(t *testing.T) {
|
||||
So(err, ShouldBeError)
|
||||
So(err.Error(), ShouldEqual, "test")
|
||||
})
|
||||
|
||||
Convey("Should stop an execution when context is cancelled", t, func() {
|
||||
c := compiler.New()
|
||||
p := c.MustCompile(`WAIT(1000) RETURN TRUE`)
|
||||
|
||||
out := make(chan Result)
|
||||
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
|
||||
go func() {
|
||||
v, err := p.Run(ctx)
|
||||
|
||||
out <- Result{
|
||||
Value: v,
|
||||
Error: err,
|
||||
}
|
||||
}()
|
||||
|
||||
cancel()
|
||||
|
||||
o := <-out
|
||||
|
||||
So(o.Error, ShouldEqual, core.ErrTerminated)
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user