MCPcopy
hub / github.com/TomWright/dasel / TestSelect

Function TestSelect

api_test.go:59–79  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

57}
58
59func 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
81func TestTernary(t *testing.T) {
82 t.Run("true literal", func(t *testing.T) {

Callers

nothing calls this directly

Calls 2

RunMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected