feat: call function with one argument

This commit is contained in:
debugtalk
2021-10-03 10:41:49 +08:00
parent 249cd5cb34
commit b32a7a32b6
3 changed files with 51 additions and 10 deletions

View File

@@ -281,6 +281,7 @@ func TestMergeVariables(t *testing.T) {
}
func TestCallFunction(t *testing.T) {
// call function without arguments
funcName := "sleep"
params := []interface{}{1}
timeStart := time.Now()
@@ -291,4 +292,15 @@ func TestCallFunction(t *testing.T) {
if !assert.Greater(t, time.Since(timeStart), time.Duration(1)*time.Second) {
t.Fail()
}
// call function with one argument
funcName = "gen_random_string"
params = []interface{}{10}
result, err := callFunction(funcName, params)
if !assert.Nil(t, err) {
t.Fail()
}
if !assert.Equal(t, 10, len(result.(string))) {
t.Fail()
}
}