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:
93
server/pkg/expr/expr_test.go
Normal file
93
server/pkg/expr/expr_test.go
Normal file
@@ -0,0 +1,93 @@
|
||||
package expr
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestVars(t *testing.T) {
|
||||
var (
|
||||
req = require.New(t)
|
||||
|
||||
vars = Must(Typify(map[string]interface{}{
|
||||
"int": Must(NewInteger(42)),
|
||||
"sub": map[string]interface{}{
|
||||
"foo": Must(NewString("foo")),
|
||||
},
|
||||
"three": map[string]interface{}{
|
||||
"two": map[string]interface{}{
|
||||
"one": map[string]interface{}{
|
||||
"go": Must(NewString("!")),
|
||||
},
|
||||
},
|
||||
},
|
||||
}))
|
||||
|
||||
tv = func(in interface{}) TypedValue {
|
||||
switch cnv := in.(type) {
|
||||
case int:
|
||||
return Must(NewInteger(cnv))
|
||||
case string:
|
||||
return Must(NewString(cnv))
|
||||
}
|
||||
|
||||
return Must(NewAny(in))
|
||||
}
|
||||
)
|
||||
|
||||
req.NoError(Assign(vars, "int", tv(123)))
|
||||
req.Equal(int64(123), Must(Select(vars, "int")).Get().(int64))
|
||||
|
||||
req.NoError(Assign(vars, "sub.foo", tv("bar")))
|
||||
req.Equal("bar", Must(Select(vars, "sub.foo")).Get().(string))
|
||||
|
||||
req.NoError(Assign(vars, "kv", &KV{}))
|
||||
req.NoError(Assign(vars, "kv.foo", tv("bar")))
|
||||
req.Equal("bar", Must(Select(vars, "kv.foo")).Get().(string))
|
||||
|
||||
req.NoError(Assign(vars, "three.two.one.go", tv("!!!")))
|
||||
req.Equal("!!!", Must(Select(vars, "three.two.one.go")).Get().(string))
|
||||
}
|
||||
|
||||
func TestAssign(t *testing.T) {
|
||||
base := &Vars{
|
||||
value: map[string]TypedValue{
|
||||
"a": &Vars{value: map[string]TypedValue{
|
||||
"b": &Vars{value: map[string]TypedValue{
|
||||
"c": &Vars{value: map[string]TypedValue{
|
||||
"d": &Vars{value: map[string]TypedValue{
|
||||
"e": &Vars{value: map[string]TypedValue{}},
|
||||
}},
|
||||
}},
|
||||
}},
|
||||
}},
|
||||
},
|
||||
}
|
||||
val := Must(NewInteger(10))
|
||||
|
||||
err := Assign(base, "a.b.c.d.e.f", val)
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
func BenchmarkAssign(b *testing.B) {
|
||||
base := &Vars{
|
||||
value: map[string]TypedValue{
|
||||
"a": &Vars{value: map[string]TypedValue{
|
||||
"b": &Vars{value: map[string]TypedValue{
|
||||
"c": &Vars{value: map[string]TypedValue{
|
||||
"d": &Vars{value: map[string]TypedValue{
|
||||
"e": &Vars{value: map[string]TypedValue{}},
|
||||
}},
|
||||
}},
|
||||
}},
|
||||
}},
|
||||
},
|
||||
}
|
||||
val := Must(NewInteger(10))
|
||||
|
||||
b.ResetTimer()
|
||||
for n := 0; n < b.N; n++ {
|
||||
Assign(base, "a.b.c.d.e.f", val)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user