github.com/TIBCOSoftware/flogo-lib@v0.5.9/core/mapper/exprmapper/expression/function/registry_test.go (about) 1 package function 2 3 import ( 4 "bytes" 5 "testing" 6 7 "github.com/stretchr/testify/assert" 8 ) 9 10 type ConcatRegistryTest struct { 11 } 12 13 func init() { 14 Registry(&ConcatRegistryTest{}) 15 } 16 17 func (s *ConcatRegistryTest) GetName() string { 18 return "concat" 19 } 20 21 func (s *ConcatRegistryTest) GetCategory() string { 22 return "test" 23 } 24 25 func (s *ConcatRegistryTest) Eval(strs ...string) string { 26 logrus.Debugf("Start test:concat function with parameters %s", strs) 27 var buffer bytes.Buffer 28 29 for _, v := range strs { 30 buffer.WriteString(v) 31 } 32 logrus.Debugf("Done test:concat function with result %s", buffer.String()) 33 return buffer.String() 34 } 35 36 func TestGetFunction(t *testing.T) { 37 f, err := GetFunction("test.concat") 38 assert.Nil(t, err) 39 assert.NotNil(t, f) 40 assert.Equal(t, "concat", f.GetName()) 41 assert.Equal(t, "test", f.GetCategory()) 42 } 43 44 func TestGetFunctionByTag(t *testing.T) { 45 f, err := GetFunctionByTag("concat", "test") 46 assert.Nil(t, err) 47 assert.NotNil(t, f) 48 assert.Equal(t, "concat", f.GetName()) 49 assert.Equal(t, "test", f.GetCategory()) 50 } 51 52 func TestListAllFunctions(t *testing.T) { 53 funcs := ListAllFunctions() 54 assert.NotNil(t, funcs) 55 }