MSP-3809 fix lint
This commit is contained in:
1 parent
439e830f67
commit
408e1cf762
8 files changed
+42
-58
No files matched your search
@@ -6,13 +6,13 @@ import (
|
||||
|
||||
stdgrpc "google.golang.org/grpc"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/txix-open/isp-kit/app"
|
||||
"github.com/txix-open/isp-kit/bootstrap"
|
||||
"github.com/txix-open/isp-kit/cluster"
|
||||
"github.com/txix-open/isp-kit/grpc"
|
||||
"github.com/txix-open/isp-kit/grpc/client"
|
||||
"github.com/txix-open/isp-kit/log"
|
||||
"github.com/pkg/errors"
|
||||
"isp-script-service/conf"
|
||||
)
|
||||
|
||||
|
||||
+3
-3
@@ -20,10 +20,10 @@ type Remote struct {
|
||||
LogLevel log.Level `schemaGen:"logLevel" schema:"Уровень логирования"`
|
||||
Scripts []ScriptDefinition
|
||||
SharedScript string
|
||||
ScriptExecutionTimeoutMs int `valid:"required~Required"`
|
||||
ScriptExecutionTimeoutMs int `valid:"required"`
|
||||
}
|
||||
|
||||
type ScriptDefinition struct {
|
||||
Id string `valid:"required~Required"`
|
||||
Script string `valid:"required~Required"`
|
||||
Id string `validate:"required"`
|
||||
Script string `validate:"required"`
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package domain
|
||||
|
||||
type GrpcError struct {
|
||||
ErrorMessage string `json:"errorMessage"`
|
||||
ErrorCode string `json:"errorCode"`
|
||||
Details []interface{} `json:"details"`
|
||||
ErrorMessage string
|
||||
ErrorCode string
|
||||
Details []interface{}
|
||||
}
|
||||
+3
-3
@@ -1,16 +1,16 @@
|
||||
package domain
|
||||
|
||||
type ExecuteByIdRequest struct {
|
||||
Id string `valid:"required~Required"`
|
||||
Id string `valid:"required"`
|
||||
Arg interface{}
|
||||
}
|
||||
|
||||
type ExecuteRequest struct {
|
||||
Script string `valid:"required~Required"`
|
||||
Script string `valid:"required"`
|
||||
Arg interface{}
|
||||
}
|
||||
|
||||
type BatchExecuteByIdsRequest struct {
|
||||
Ids []string `valid:"required~Required"`
|
||||
Ids []string `valid:"required"`
|
||||
Arg interface{}
|
||||
}
|
||||
@@ -4,8 +4,8 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/txix-open/isp-kit/grpc/client"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/txix-open/isp-kit/grpc/client"
|
||||
md "google.golang.org/grpc/metadata"
|
||||
)
|
||||
|
||||
|
||||
+1
-1
@@ -10,9 +10,9 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/txix-open/isp-kit/log"
|
||||
"github.com/txix-open/isp-script"
|
||||
"github.com/pkg/errors"
|
||||
"isp-script-service/conf"
|
||||
"isp-script-service/domain"
|
||||
)
|
||||
|
||||
@@ -4,11 +4,11 @@ import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/stretchr/testify/suite"
|
||||
"github.com/txix-open/isp-kit/grpc/client"
|
||||
"github.com/txix-open/isp-kit/test"
|
||||
"github.com/txix-open/isp-kit/test/grpct"
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/stretchr/testify/suite"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
"isp-script-service/assembly"
|
||||
@@ -64,7 +64,7 @@ func (s *ApiScript) TestExternalInvoke() {
|
||||
JsonResponseBody(&res).
|
||||
Do(context.Background())
|
||||
s.Require().NoError(err)
|
||||
s.Require().Equal(res.Result, true)
|
||||
s.Require().Equal(true, res.Result)
|
||||
}
|
||||
|
||||
func (s *ApiScript) TestExecuteHappyPath() {
|
||||
@@ -80,7 +80,7 @@ func (s *ApiScript) TestExecuteHappyPath() {
|
||||
JsonResponseBody(&res).
|
||||
Do(context.Background())
|
||||
s.Require().NoError(err)
|
||||
s.Require().Equal(res.Result, true)
|
||||
s.Require().Equal(true, res.Result)
|
||||
}
|
||||
|
||||
func (s *ApiScript) TestExecuteByIdHappyPath() {
|
||||
@@ -94,7 +94,7 @@ func (s *ApiScript) TestExecuteByIdHappyPath() {
|
||||
JsonResponseBody(&res).
|
||||
Do(context.Background())
|
||||
s.Require().NoError(err)
|
||||
s.Require().Equal(res.Result, true)
|
||||
s.Require().Equal(true, res.Result)
|
||||
}
|
||||
|
||||
func (s *ApiScript) TestExecuteByIdNotFound() {
|
||||
|
||||
+25
-41
@@ -2,14 +2,14 @@
|
||||
package tests_test
|
||||
|
||||
import (
|
||||
json2 "encoding/json"
|
||||
json2 "github.com/txix-open/isp-kit/json"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/dop251/goja"
|
||||
"github.com/robertkrimen/otto"
|
||||
"github.com/robertkrimen/otto/parser"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
lua "github.com/yuin/gopher-lua"
|
||||
"github.com/yuin/gopher-lua/parse"
|
||||
json "layeh.com/gopher-json"
|
||||
@@ -76,48 +76,37 @@ func init() {
|
||||
|
||||
func TestOtto(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
assert := assert.New(t)
|
||||
require := require.New(t)
|
||||
|
||||
prog, err := parser.ParseFile(nil, "example", jsScript, 0)
|
||||
if !assert.NoError(err) {
|
||||
return
|
||||
}
|
||||
//
|
||||
require.NoError(err)
|
||||
|
||||
runTime := otto.New()
|
||||
err = runTime.Set("b", recordsExample)
|
||||
if !assert.NoError(err) {
|
||||
return
|
||||
}
|
||||
require.NoError(err)
|
||||
|
||||
_, err = runTime.Run(prog)
|
||||
if !assert.NoError(err) {
|
||||
return
|
||||
}
|
||||
require.NoError(err)
|
||||
|
||||
res, err := runTime.Get("a")
|
||||
if !assert.NoError(err) {
|
||||
return
|
||||
}
|
||||
require.NoError(err)
|
||||
|
||||
_, err = res.Export()
|
||||
if !assert.NoError(err) {
|
||||
return
|
||||
}
|
||||
require.NoError(err)
|
||||
}
|
||||
|
||||
func TestGoja(t *testing.T) {
|
||||
t.Parallel()
|
||||
require := require.New(t)
|
||||
|
||||
prog := goja.MustCompile("test.js", jsScript, false)
|
||||
//
|
||||
assert := assert.New(t)
|
||||
|
||||
runTime := goja.New()
|
||||
err := runTime.Set("b", recordsExample)
|
||||
assert.NoError(err)
|
||||
require.NoError(err)
|
||||
|
||||
_, err = runTime.RunProgram(prog)
|
||||
assert.NoError(err)
|
||||
require.NoError(err)
|
||||
|
||||
a := runTime.Get("a")
|
||||
_ = a.Export()
|
||||
@@ -125,36 +114,31 @@ func TestGoja(t *testing.T) {
|
||||
|
||||
func TestGopherLua(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
assert := assert.New(t)
|
||||
require := require.New(t)
|
||||
|
||||
l := lua.NewState()
|
||||
defer l.Close()
|
||||
|
||||
b, err := json2.Marshal(recordsExample)
|
||||
assert.NoError(err)
|
||||
require.NoError(err)
|
||||
|
||||
val, err := json.Decode(l, b)
|
||||
if !assert.NoError(err) {
|
||||
return
|
||||
}
|
||||
require.NoError(err)
|
||||
|
||||
l.SetGlobal("src", val)
|
||||
|
||||
//
|
||||
err = l.DoString(luaScript)
|
||||
if !assert.NoError(err) {
|
||||
return
|
||||
}
|
||||
require.NoError(err)
|
||||
|
||||
dst := l.GetGlobal("dst")
|
||||
b, err = json.Encode(dst)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
require.NoError(err)
|
||||
|
||||
m := make(map[string]interface{})
|
||||
err = json2.Unmarshal(b, &m)
|
||||
if !assert.NoError(err) {
|
||||
return
|
||||
}
|
||||
assert.EqualValues(expecting, m)
|
||||
require.NoError(err)
|
||||
|
||||
require.EqualValues(expecting, m)
|
||||
}
|
||||
|
||||
func BenchmarkOtto(b *testing.B) {
|
||||
|
||||
Reference in new issue
Block a user