MSP-1905 update dependencies
This commit is contained in:
1 parent
db6fa9aab6
commit
4a74b91e41
13 files changed
+164
-592
No files matched your search
@@ -1,4 +1,4 @@
|
||||
package tests
|
||||
package tests_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -17,6 +17,7 @@ import (
|
||||
)
|
||||
|
||||
func TestApiScriptTestSuite(t *testing.T) {
|
||||
t.Parallel()
|
||||
suite.Run(t, &ApiScript{})
|
||||
}
|
||||
|
||||
@@ -60,7 +61,7 @@ func (s *ApiScript) TestExternalInvoke() {
|
||||
res := domain.ScriptResp{}
|
||||
err := s.apiCli.Invoke("script/script/execute").
|
||||
JsonRequestBody(req).
|
||||
ReadJsonResponse(&res).
|
||||
JsonResponseBody(&res).
|
||||
Do(context.Background())
|
||||
s.Require().NoError(err)
|
||||
s.Require().Equal(res.Result, true)
|
||||
@@ -76,7 +77,7 @@ func (s *ApiScript) TestExecuteHappyPath() {
|
||||
res := domain.ScriptResp{}
|
||||
err := s.apiCli.Invoke("script/script/execute").
|
||||
JsonRequestBody(req).
|
||||
ReadJsonResponse(&res).
|
||||
JsonResponseBody(&res).
|
||||
Do(context.Background())
|
||||
s.Require().NoError(err)
|
||||
s.Require().Equal(res.Result, true)
|
||||
@@ -90,7 +91,7 @@ func (s *ApiScript) TestExecuteByIdHappyPath() {
|
||||
res := domain.ScriptResp{}
|
||||
err := s.apiCli.Invoke("script/script/execute_by_id").
|
||||
JsonRequestBody(req).
|
||||
ReadJsonResponse(&res).
|
||||
JsonResponseBody(&res).
|
||||
Do(context.Background())
|
||||
s.Require().NoError(err)
|
||||
s.Require().Equal(res.Result, true)
|
||||
@@ -104,7 +105,7 @@ func (s *ApiScript) TestExecuteByIdNotFound() {
|
||||
res := domain.ScriptResp{}
|
||||
err := s.apiCli.Invoke("script/script/execute_by_id").
|
||||
JsonRequestBody(req).
|
||||
ReadJsonResponse(&res).
|
||||
JsonResponseBody(&res).
|
||||
Do(context.Background())
|
||||
s.Require().Error(err)
|
||||
st, ok := status.FromError(err)
|
||||
@@ -126,7 +127,7 @@ func (s *ApiScript) TestBatchExecuteHappyPath() {
|
||||
res := make([]domain.ScriptResp, 0)
|
||||
err := s.apiCli.Invoke("script/script/batch_execute").
|
||||
JsonRequestBody(req).
|
||||
ReadJsonResponse(&res).
|
||||
JsonResponseBody(&res).
|
||||
Do(context.Background())
|
||||
s.Require().NoError(err)
|
||||
expected := []domain.ScriptResp{
|
||||
@@ -150,7 +151,7 @@ func (s *ApiScript) TestBatchExecuteMixedNotFound() {
|
||||
res := make([]domain.ScriptResp, 0)
|
||||
err := s.apiCli.Invoke("script/script/batch_execute").
|
||||
JsonRequestBody(req).
|
||||
ReadJsonResponse(&res).
|
||||
JsonResponseBody(&res).
|
||||
Do(context.Background())
|
||||
s.Require().NoError(err)
|
||||
expected := []domain.ScriptResp{
|
||||
@@ -171,7 +172,7 @@ func (s *ApiScript) TestBatchExecuteByIdHappyPath() {
|
||||
res := make([]domain.ScriptResp, 0)
|
||||
err := s.apiCli.Invoke("script/script/batch_execute_by_ids").
|
||||
JsonRequestBody(req).
|
||||
ReadJsonResponse(&res).
|
||||
JsonResponseBody(&res).
|
||||
Do(context.Background())
|
||||
s.Require().NoError(err)
|
||||
expected := []domain.ScriptResp{
|
||||
|
||||
+27
-10
@@ -1,4 +1,5 @@
|
||||
package tests
|
||||
// nolint:gochecknoglobals
|
||||
package tests_test
|
||||
|
||||
import (
|
||||
json2 "encoding/json"
|
||||
@@ -61,9 +62,10 @@ var (
|
||||
expecting = make(map[string]interface{})
|
||||
)
|
||||
|
||||
// nolint:gochecknoinits
|
||||
func init() {
|
||||
for _, v := range recordsExample {
|
||||
expecting[v["id_tp_cd"].(string)] = v
|
||||
expecting[v["id_tp_cd"].(string)] = v // nolint:forcetypeassert
|
||||
}
|
||||
if bytes, err := json2.Marshal(recordsExample); err != nil {
|
||||
panic(err)
|
||||
@@ -73,6 +75,8 @@ func init() {
|
||||
}
|
||||
|
||||
func TestOtto(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
assert := assert.New(t)
|
||||
|
||||
prog, err := parser.ParseFile(nil, "example", jsScript, 0)
|
||||
@@ -102,25 +106,33 @@ func TestOtto(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGoja(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
prog := goja.MustCompile("test.js", jsScript, false)
|
||||
//
|
||||
assert := assert.New(t)
|
||||
|
||||
runTime := goja.New()
|
||||
runTime.Set("b", recordsExample)
|
||||
_, err := runTime.RunProgram(prog)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
err := runTime.Set("b", recordsExample)
|
||||
assert.NoError(err)
|
||||
|
||||
_, err = runTime.RunProgram(prog)
|
||||
assert.NoError(err)
|
||||
|
||||
a := runTime.Get("a")
|
||||
_ = a.Export()
|
||||
}
|
||||
|
||||
func TestGopherLua(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
assert := assert.New(t)
|
||||
|
||||
l := lua.NewState()
|
||||
defer l.Close()
|
||||
|
||||
b, _ := json2.Marshal(recordsExample)
|
||||
b, err := json2.Marshal(recordsExample)
|
||||
assert.NoError(err)
|
||||
val, err := json.Decode(l, b)
|
||||
if !assert.NoError(err) {
|
||||
return
|
||||
@@ -179,11 +191,16 @@ func BenchmarkGoja(b *testing.B) {
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
runTime := goja.New()
|
||||
runTime.Set("b", recordsExample)
|
||||
_, err := runTime.RunProgram(prog)
|
||||
err := runTime.Set("b", recordsExample)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
_, err = runTime.RunProgram(prog)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
a := runTime.Get("a")
|
||||
_ = a.Export()
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user