1
0
mirror of https://github.com/MontFerret/ferret.git synced 2025-12-01 22:19:32 +02:00

allow context cancellation in WAIT (#524)

* allow context cancellation in WAIT

* cancel context before running the program
This commit is contained in:
Paul
2020-06-01 13:58:16 +02:00
committed by GitHub
parent 94f13c66af
commit aa058f3542
2 changed files with 10 additions and 16 deletions

View File

@@ -32,23 +32,11 @@ func TestProgram(t *testing.T) {
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
_, err := p.Run(ctx)
So(o.Error, ShouldEqual, core.ErrTerminated)
So(err, ShouldEqual, core.ErrTerminated)
})
}