Skip to content

Commit

Permalink
feat: Provide Signal method (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
vircoys authored Aug 5, 2023
1 parent c610f88 commit 470af95
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/engine/runtime/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ func (ctx *Context) InData() any {
}
}

func (ctx *Context) Signal() Signal {
return ctx.signal
}

func InitCtxWithoutMap(ctx *Context, inWithoutMap InputWithoutMap, funcs map[string]FuncCall,
callRef []*ast.CallExpr, signal Signal, name, content string,
) *Context {
Expand Down
20 changes: 20 additions & 0 deletions pkg/engine/runtime/runtime_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,26 @@ func TestInExpr(t *testing.T) {
}, inData.data)
}

type sign struct {
}

func (s *sign) ExitSignal() bool {
return false
}

func TestSignal(t *testing.T) {
s := func() Signal {
return (*sign)(nil)
}()

ctx := &Context{
signal: s,
}

sig := ctx.Signal()
assert.Equal(t, false, sig == nil)
}

func TestUnaryAndAssignOP(t *testing.T) {
cases := []struct {
name string
Expand Down

0 comments on commit 470af95

Please sign in to comment.