snapshot of https://github.com/cortezaproject/corteza.git (2024.9.x, 2026-09-18; blobs > 131072B omitted)
Some checks failed
SonarQube / SonarQube (push) Failing after 5m28s
E2e test on main branch push / server and client test (map[name:admin port:8080]) (push) Failing after 3m33s
Server and lib tests / Library test (js) (push) Failing after 1m36s
Server and lib tests / Library test (vue) (push) Successful in 2m24s
Server and lib tests / Web client test (admin) (push) Successful in 2m52s
Server and lib tests / Web client test (compose) (push) Successful in 3m23s
Server and lib tests / Web client test (discovery) (push) Successful in 2m49s
Server and lib tests / Web client test (one) (push) Successful in 2m52s
Server and lib tests / Web client test (privacy) (push) Successful in 2m44s
Server and lib tests / Web client test (reporter) (push) Successful in 2m56s
Server and lib tests / Web client test (workflow) (push) Successful in 3m0s
Server and lib tests / Server tests (push) Failing after 4m55s
E2e test on main branch push / notify-failure (push) Failing after 9s
Server and lib tests / Send matrix testing notification (push) Successful in 2s
Mark stale issues and pull requests / stale (push) Successful in 40s
Some checks failed
SonarQube / SonarQube (push) Failing after 5m28s
E2e test on main branch push / server and client test (map[name:admin port:8080]) (push) Failing after 3m33s
Server and lib tests / Library test (js) (push) Failing after 1m36s
Server and lib tests / Library test (vue) (push) Successful in 2m24s
Server and lib tests / Web client test (admin) (push) Successful in 2m52s
Server and lib tests / Web client test (compose) (push) Successful in 3m23s
Server and lib tests / Web client test (discovery) (push) Successful in 2m49s
Server and lib tests / Web client test (one) (push) Successful in 2m52s
Server and lib tests / Web client test (privacy) (push) Successful in 2m44s
Server and lib tests / Web client test (reporter) (push) Successful in 2m56s
Server and lib tests / Web client test (workflow) (push) Successful in 3m0s
Server and lib tests / Server tests (push) Failing after 4m55s
E2e test on main branch push / notify-failure (push) Failing after 9s
Server and lib tests / Send matrix testing notification (push) Successful in 2s
Mark stale issues and pull requests / stale (push) Successful in 40s
This commit is contained in:
114
server/pkg/wfexec/gateways_test.go
Normal file
114
server/pkg/wfexec/gateways_test.go
Normal file
@@ -0,0 +1,114 @@
|
||||
package wfexec
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/cortezaproject/corteza/server/pkg/expr"
|
||||
"github.com/spf13/cast"
|
||||
"github.com/stretchr/testify/require"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func gt(key string, val int64) pathTester {
|
||||
return func(ctx context.Context, variables *expr.Vars) (bool, error) {
|
||||
return cast.ToInt64(expr.Must(expr.Select(variables, key)).Get()) > val, nil
|
||||
}
|
||||
}
|
||||
|
||||
func makeIntVars(k string, num int) *expr.Vars {
|
||||
o := &expr.Vars{}
|
||||
_ = o.Set(k, num)
|
||||
return o
|
||||
}
|
||||
|
||||
func TestJoinGateway(t *testing.T) {
|
||||
var (
|
||||
req = require.New(t)
|
||||
p1, p2, p3 = &wfTestStep{name: "p1"}, &wfTestStep{name: "p2"}, &wfTestStep{name: "p3"}
|
||||
gw = JoinGateway(p1, p2, p3)
|
||||
|
||||
r ExecResponse
|
||||
err error
|
||||
)
|
||||
|
||||
r, err = gw.Exec(context.TODO(), &ExecRequest{Parent: p1, SessionID: 1})
|
||||
req.NoError(err)
|
||||
req.Equal(&partial{}, r)
|
||||
|
||||
r, err = gw.Exec(context.TODO(), &ExecRequest{Parent: p2, SessionID: 1})
|
||||
req.NoError(err)
|
||||
req.Equal(&partial{}, r)
|
||||
|
||||
r, err = gw.Exec(context.TODO(), &ExecRequest{Parent: p3, SessionID: 1})
|
||||
req.NoError(err)
|
||||
req.IsType(&joined{}, r)
|
||||
|
||||
r, err = gw.Exec(context.TODO(), &ExecRequest{Parent: p1, SessionID: 2})
|
||||
req.NoError(err)
|
||||
req.Equal(&partial{}, r)
|
||||
}
|
||||
|
||||
func TestForkGateway(t *testing.T) {
|
||||
var (
|
||||
req = require.New(t)
|
||||
gw = ForkGateway()
|
||||
)
|
||||
|
||||
r, err := gw.Exec(context.TODO(), nil)
|
||||
req.NoError(err)
|
||||
req.Equal(Steps{}, r)
|
||||
req.Empty(r)
|
||||
}
|
||||
|
||||
func TestInclGateway(t *testing.T) {
|
||||
var (
|
||||
req = require.New(t)
|
||||
|
||||
s1, s2, s3 = &wfTestStep{name: "s1"}, &wfTestStep{name: "s2"}, &wfTestStep{name: "s3"}
|
||||
gwp1, _ = NewGatewayPath(s1, gt("a", 10))
|
||||
gwp2, _ = NewGatewayPath(s2, gt("a", 5))
|
||||
gwp3, _ = NewGatewayPath(s3, gt("a", 0))
|
||||
|
||||
gw, err = InclGateway(gwp1, gwp2, gwp3)
|
||||
)
|
||||
|
||||
r, err := gw.Exec(context.Background(), &ExecRequest{Scope: makeIntVars("a", 11)})
|
||||
req.NoError(err)
|
||||
req.Equal(Steps{s1, s2, s3}, r)
|
||||
|
||||
r, err = gw.Exec(context.Background(), &ExecRequest{Scope: makeIntVars("a", 6)})
|
||||
req.NoError(err)
|
||||
req.Equal(Steps{s2, s3}, r)
|
||||
|
||||
r, err = gw.Exec(context.Background(), &ExecRequest{Scope: makeIntVars("a", 1)})
|
||||
req.NoError(err)
|
||||
req.Equal(Steps{s3}, r)
|
||||
|
||||
r, err = gw.Exec(context.Background(), &ExecRequest{Scope: makeIntVars("a", 0)})
|
||||
req.Error(err)
|
||||
req.Nil(r)
|
||||
}
|
||||
|
||||
func TestExclGateway(t *testing.T) {
|
||||
var (
|
||||
req = require.New(t)
|
||||
|
||||
s1, s2, s3 = &wfTestStep{name: "s1"}, &wfTestStep{name: "s2"}, &wfTestStep{name: "s3"}
|
||||
gwp1, _ = NewGatewayPath(s1, gt("a", 10))
|
||||
gwp2, _ = NewGatewayPath(s2, gt("a", 5))
|
||||
gwp3, _ = NewGatewayPath(s3, nil)
|
||||
|
||||
gw, err = ExclGateway(gwp1, gwp2, gwp3)
|
||||
)
|
||||
|
||||
r, err := gw.Exec(context.Background(), &ExecRequest{Scope: makeIntVars("a", 11)})
|
||||
req.NoError(err)
|
||||
req.Equal(s1, r)
|
||||
|
||||
r, err = gw.Exec(context.Background(), &ExecRequest{Scope: makeIntVars("a", 6)})
|
||||
req.NoError(err)
|
||||
req.Equal(s2, r)
|
||||
|
||||
r, err = gw.Exec(context.Background(), &ExecRequest{Scope: makeIntVars("a", 1)})
|
||||
req.NoError(err)
|
||||
req.Equal(s3, r)
|
||||
}
|
||||
Reference in New Issue
Block a user