util_test.go 1022 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package common
  2. import (
  3. "reflect"
  4. "strings"
  5. "testing"
  6. )
  7. func TestMapConvert_Funcs(t *testing.T) {
  8. source := map[interface{}]interface{}{
  9. "QUERY_TABLE": "VBAP",
  10. "ROWCOUNT": 10,
  11. "FIELDS": []interface{}{
  12. map[interface{}]interface{}{"FIELDNAME": "MANDT"},
  13. map[interface{}]interface{}{"FIELDNAME": "VBELN"},
  14. map[interface{}]interface{}{"FIELDNAME": "POSNR"},
  15. },
  16. }
  17. exp := map[string]interface{}{
  18. "QUERY_TABLE": "VBAP",
  19. "ROWCOUNT": 10,
  20. "FIELDS": []interface{}{
  21. map[string]interface{}{"FIELDNAME": "MANDT"},
  22. map[string]interface{}{"FIELDNAME": "VBELN"},
  23. map[string]interface{}{"FIELDNAME": "POSNR"},
  24. },
  25. }
  26. got := ConvertMap(source)
  27. if !reflect.DeepEqual(exp, got) {
  28. t.Errorf("result mismatch:\n\nexp=%s\n\ngot=%s\n\n", exp, got)
  29. }
  30. }
  31. func TestGetDataLoc_Funcs(t *testing.T) {
  32. d, err := GetDataLoc()
  33. if err != nil {
  34. t.Errorf("Errors when getting data loc: %s.", err)
  35. } else if !strings.HasSuffix(d, "kuiper/data/test") {
  36. t.Errorf("Unexpected data location %s", d)
  37. }
  38. }