| 57 | } |
| 58 | |
| 59 | func TestSelect(t *testing.T) { |
| 60 | t.Run("basic select", func(t *testing.T) { |
| 61 | inputData := map[string]any{ |
| 62 | "users": []map[string]any{ |
| 63 | {"name": "Alice", "age": 30}, |
| 64 | {"name": "Bob", "age": 25}, |
| 65 | }, |
| 66 | } |
| 67 | result, count, err := dasel.Select(t.Context(), inputData, "users.map(name)...") |
| 68 | if err != nil { |
| 69 | t.Fatalf("unexpected error: %v", err) |
| 70 | } |
| 71 | if count != 2 { |
| 72 | t.Errorf("unexpected count: %d", count) |
| 73 | } |
| 74 | exp := []any{"Alice", "Bob"} |
| 75 | if !cmp.Equal(exp, result) { |
| 76 | t.Errorf("unexpected result: %s", cmp.Diff(exp, result)) |
| 77 | } |
| 78 | }) |
| 79 | } |
| 80 | |
| 81 | func TestTernary(t *testing.T) { |
| 82 | t.Run("true literal", func(t *testing.T) { |