source_node_test.go 1002 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. package nodes
  2. import (
  3. "github.com/emqx/kuiper/common"
  4. "github.com/emqx/kuiper/xstream/contexts"
  5. "reflect"
  6. "testing"
  7. )
  8. func TestGetConf_Apply(t *testing.T) {
  9. result := map[string]interface{}{
  10. "interval": 1000,
  11. "ashost": "192.168.1.100",
  12. "sysnr": "02",
  13. "client": "900",
  14. "user": "SPERF",
  15. "passwd": "PASSPASS",
  16. "params": map[string]interface{}{
  17. "QUERY_TABLE": "VBAP",
  18. "ROWCOUNT": 10,
  19. "FIELDS": []interface{}{
  20. map[string]interface{}{"FIELDNAME": "MANDT"},
  21. map[string]interface{}{"FIELDNAME": "VBELN"},
  22. map[string]interface{}{"FIELDNAME": "POSNR"},
  23. },
  24. },
  25. }
  26. n := NewSourceNode("test", map[string]string{
  27. "DATASOURCE": "RFC_READ_TABLE",
  28. "TYPE": "test",
  29. })
  30. contextLogger := common.Log.WithField("rule", "test")
  31. ctx := contexts.WithValue(contexts.Background(), contexts.LoggerKey, contextLogger)
  32. conf := n.getConf(ctx)
  33. if !reflect.DeepEqual(result, conf) {
  34. t.Errorf("result mismatch:\n\nexp=%s\n\ngot=%s\n\n", result, conf)
  35. }
  36. }