| 1 | package dasel_testscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3_test`/ |
| 2 | |
| 3 | import ( |
| 4 | "testingscip-go gomod github.com/golang/go/src go1.25 testing/" |
| 5 | |
| 6 | "github.com/google/go-cmp/cmpscip-go gomod github.com/google/go-cmp v0.7.0 `github.com/google/go-cmp/cmp`/" |
| 7 | "github.com/tomwright/dasel/v3scip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3`/" |
| 8 | ) |
| 9 | |
| 10 | type modifyTestCasescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3_test`/modifyTestCase# struct { |
| 11 | selectorscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3_test`/modifyTestCase#selector. string |
| 12 | inscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3_test`/modifyTestCase#in. any |
| 13 | valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3_test`/modifyTestCase#value. any |
| 14 | expscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3_test`/modifyTestCase#exp. any |
| 15 | countscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3_test`/modifyTestCase#count. int |
| 16 | } |
| 17 | |
| 18 | func (tc modifyTestCasescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3_test`/modifyTestCase#) runscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3_test`/modifyTestCase#run().(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) { |
| 19 | count, err := daselscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3`/.Modifyscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3`/Modify().(t.Contextscip-go gomod github.com/golang/go/src go1.25 testing/common#Context().(), &tc.inscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3_test`/modifyTestCase#in., tc.selectorscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3_test`/modifyTestCase#selector., tc.valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3_test`/modifyTestCase#value.) |
| 20 | if err != nil { |
| 21 | t.Fatalfscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatalf().("unexpected error: %v", err) |
| 22 | } |
| 23 | if count != tc.countscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3_test`/modifyTestCase#count. { |
| 24 | t.Errorfscip-go gomod github.com/golang/go/src go1.25 testing/common#Errorf().("unexpected count: %d", count) |
| 25 | } |
| 26 | if !cmpscip-go gomod github.com/google/go-cmp v0.7.0 `github.com/google/go-cmp/cmp`/.Equalscip-go gomod github.com/google/go-cmp v0.7.0 `github.com/google/go-cmp/cmp`/Equal().(tc.expscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3_test`/modifyTestCase#exp., tc.inscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3_test`/modifyTestCase#in.) { |
| 27 | t.Errorfscip-go gomod github.com/golang/go/src go1.25 testing/common#Errorf().("unexpected result: %s", cmpscip-go gomod github.com/google/go-cmp v0.7.0 `github.com/google/go-cmp/cmp`/.Diffscip-go gomod github.com/google/go-cmp v0.7.0 `github.com/google/go-cmp/cmp`/Diff().(tc.expscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3_test`/modifyTestCase#exp., tc.inscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3_test`/modifyTestCase#in.)) |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | func TestQueryscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3_test`/TestQuery().(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) { |
| 32 | t.Runscip-go gomod github.com/golang/go/src go1.25 testing/T#Run().("basic query", func(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) { |
| 33 | inputData := map[string]any{ |
| 34 | "users": []map[string]any{ |
| 35 | {"name": "Alice", "age": 30}, |
| 36 | {"name": "Bob", "age": 25}, |
| 37 | }, |
| 38 | } |
| 39 | results, count, err := daselscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3`/.Queryscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3`/Query().(t.Contextscip-go gomod github.com/golang/go/src go1.25 testing/common#Context().(), inputData, "users.map(name)...") |
| 40 | if err != nil { |
| 41 | t.Fatalfscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatalf().("unexpected error: %v", err) |
| 42 | } |
| 43 | if count != 2 { |
| 44 | t.Errorfscip-go gomod github.com/golang/go/src go1.25 testing/common#Errorf().("unexpected count: %d", count) |
| 45 | } |
| 46 | exp := []string{"Alice", "Bob"} |
| 47 | for i, r := range results { |
| 48 | strVal, err := r.StringValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#StringValue().() |
| 49 | if err != nil { |
| 50 | t.Fatalfscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatalf().("unexpected error: %v", err) |
| 51 | } |
| 52 | if strVal != exp[i] { |
| 53 | t.Errorfscip-go gomod github.com/golang/go/src go1.25 testing/common#Errorf().("unexpected result at index %d: %s", i, strVal) |
| 54 | } |
| 55 | } |
| 56 | }) |
| 57 | } |
| 58 | |
| 59 | func TestSelectscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3_test`/TestSelect().(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) { |
| 60 | t.Runscip-go gomod github.com/golang/go/src go1.25 testing/T#Run().("basic select", func(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 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 := daselscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3`/.Selectscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3`/Select().(t.Contextscip-go gomod github.com/golang/go/src go1.25 testing/common#Context().(), inputData, "users.map(name)...") |
| 68 | if err != nil { |
| 69 | t.Fatalfscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatalf().("unexpected error: %v", err) |
| 70 | } |
| 71 | if count != 2 { |
| 72 | t.Errorfscip-go gomod github.com/golang/go/src go1.25 testing/common#Errorf().("unexpected count: %d", count) |
| 73 | } |
| 74 | exp := []any{"Alice", "Bob"} |
| 75 | if !cmpscip-go gomod github.com/google/go-cmp v0.7.0 `github.com/google/go-cmp/cmp`/.Equalscip-go gomod github.com/google/go-cmp v0.7.0 `github.com/google/go-cmp/cmp`/Equal().(exp, result) { |
| 76 | t.Errorfscip-go gomod github.com/golang/go/src go1.25 testing/common#Errorf().("unexpected result: %s", cmpscip-go gomod github.com/google/go-cmp v0.7.0 `github.com/google/go-cmp/cmp`/.Diffscip-go gomod github.com/google/go-cmp v0.7.0 `github.com/google/go-cmp/cmp`/Diff().(exp, result)) |
| 77 | } |
| 78 | }) |
| 79 | } |
| 80 | |
| 81 | func TestTernaryscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3_test`/TestTernary().(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) { |
| 82 | t.Runscip-go gomod github.com/golang/go/src go1.25 testing/T#Run().("true literal", func(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) { |
| 83 | result, count, err := daselscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3`/.Selectscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3`/Select().(t.Contextscip-go gomod github.com/golang/go/src go1.25 testing/common#Context().(), nil, `true ? "yes" : "no"`) |
| 84 | if err != nil { |
| 85 | t.Fatalfscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatalf().("unexpected error: %v", err) |
| 86 | } |
| 87 | if count != 1 { |
| 88 | t.Errorfscip-go gomod github.com/golang/go/src go1.25 testing/common#Errorf().("unexpected count: %d", count) |
| 89 | } |
| 90 | exp := []any{"yes"} |
| 91 | if !cmpscip-go gomod github.com/google/go-cmp v0.7.0 `github.com/google/go-cmp/cmp`/.Equalscip-go gomod github.com/google/go-cmp v0.7.0 `github.com/google/go-cmp/cmp`/Equal().(exp, result) { |
| 92 | t.Errorfscip-go gomod github.com/golang/go/src go1.25 testing/common#Errorf().("unexpected result: %s", cmpscip-go gomod github.com/google/go-cmp v0.7.0 `github.com/google/go-cmp/cmp`/.Diffscip-go gomod github.com/google/go-cmp v0.7.0 `github.com/google/go-cmp/cmp`/Diff().(exp, result)) |
| 93 | } |
| 94 | }) |
| 95 | t.Runscip-go gomod github.com/golang/go/src go1.25 testing/T#Run().("false literal", func(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) { |
| 96 | result, count, err := daselscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3`/.Selectscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3`/Select().(t.Contextscip-go gomod github.com/golang/go/src go1.25 testing/common#Context().(), nil, `false ? "yes" : "no"`) |
| 97 | if err != nil { |
| 98 | t.Fatalfscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatalf().("unexpected error: %v", err) |
| 99 | } |
| 100 | if count != 1 { |
| 101 | t.Errorfscip-go gomod github.com/golang/go/src go1.25 testing/common#Errorf().("unexpected count: %d", count) |
| 102 | } |
| 103 | exp := []any{"no"} |
| 104 | if !cmpscip-go gomod github.com/google/go-cmp v0.7.0 `github.com/google/go-cmp/cmp`/.Equalscip-go gomod github.com/google/go-cmp v0.7.0 `github.com/google/go-cmp/cmp`/Equal().(exp, result) { |
| 105 | t.Errorfscip-go gomod github.com/golang/go/src go1.25 testing/common#Errorf().("unexpected result: %s", cmpscip-go gomod github.com/google/go-cmp v0.7.0 `github.com/google/go-cmp/cmp`/.Diffscip-go gomod github.com/google/go-cmp v0.7.0 `github.com/google/go-cmp/cmp`/Diff().(exp, result)) |
| 106 | } |
| 107 | }) |
| 108 | t.Runscip-go gomod github.com/golang/go/src go1.25 testing/T#Run().("condition with comparison", func(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) { |
| 109 | inputData := map[string]any{"score": 85} |
| 110 | result, count, err := daselscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3`/.Selectscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3`/Select().(t.Contextscip-go gomod github.com/golang/go/src go1.25 testing/common#Context().(), inputData, `score >= 70 ? "pass" : "fail"`) |
| 111 | if err != nil { |
| 112 | t.Fatalfscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatalf().("unexpected error: %v", err) |
| 113 | } |
| 114 | if count != 1 { |
| 115 | t.Errorfscip-go gomod github.com/golang/go/src go1.25 testing/common#Errorf().("unexpected count: %d", count) |
| 116 | } |
| 117 | exp := []any{"pass"} |
| 118 | if !cmpscip-go gomod github.com/google/go-cmp v0.7.0 `github.com/google/go-cmp/cmp`/.Equalscip-go gomod github.com/google/go-cmp v0.7.0 `github.com/google/go-cmp/cmp`/Equal().(exp, result) { |
| 119 | t.Errorfscip-go gomod github.com/golang/go/src go1.25 testing/common#Errorf().("unexpected result: %s", cmpscip-go gomod github.com/google/go-cmp v0.7.0 `github.com/google/go-cmp/cmp`/.Diffscip-go gomod github.com/google/go-cmp v0.7.0 `github.com/google/go-cmp/cmp`/Diff().(exp, result)) |
| 120 | } |
| 121 | }) |
| 122 | t.Runscip-go gomod github.com/golang/go/src go1.25 testing/T#Run().("condition with comparison false", func(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) { |
| 123 | inputData := map[string]any{"score": 50} |
| 124 | result, count, err := daselscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3`/.Selectscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3`/Select().(t.Contextscip-go gomod github.com/golang/go/src go1.25 testing/common#Context().(), inputData, `score >= 70 ? "pass" : "fail"`) |
| 125 | if err != nil { |
| 126 | t.Fatalfscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatalf().("unexpected error: %v", err) |
| 127 | } |
| 128 | if count != 1 { |
| 129 | t.Errorfscip-go gomod github.com/golang/go/src go1.25 testing/common#Errorf().("unexpected count: %d", count) |
| 130 | } |
| 131 | exp := []any{"fail"} |
| 132 | if !cmpscip-go gomod github.com/google/go-cmp v0.7.0 `github.com/google/go-cmp/cmp`/.Equalscip-go gomod github.com/google/go-cmp v0.7.0 `github.com/google/go-cmp/cmp`/Equal().(exp, result) { |
| 133 | t.Errorfscip-go gomod github.com/golang/go/src go1.25 testing/common#Errorf().("unexpected result: %s", cmpscip-go gomod github.com/google/go-cmp v0.7.0 `github.com/google/go-cmp/cmp`/.Diffscip-go gomod github.com/google/go-cmp v0.7.0 `github.com/google/go-cmp/cmp`/Diff().(exp, result)) |
| 134 | } |
| 135 | }) |
| 136 | t.Runscip-go gomod github.com/golang/go/src go1.25 testing/T#Run().("nested ternary", func(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) { |
| 137 | result, count, err := daselscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3`/.Selectscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3`/Select().(t.Contextscip-go gomod github.com/golang/go/src go1.25 testing/common#Context().(), nil, `true ? (false ? "a" : "b") : "c"`) |
| 138 | if err != nil { |
| 139 | t.Fatalfscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatalf().("unexpected error: %v", err) |
| 140 | } |
| 141 | if count != 1 { |
| 142 | t.Errorfscip-go gomod github.com/golang/go/src go1.25 testing/common#Errorf().("unexpected count: %d", count) |
| 143 | } |
| 144 | exp := []any{"b"} |
| 145 | if !cmpscip-go gomod github.com/google/go-cmp v0.7.0 `github.com/google/go-cmp/cmp`/.Equalscip-go gomod github.com/google/go-cmp v0.7.0 `github.com/google/go-cmp/cmp`/Equal().(exp, result) { |
| 146 | t.Errorfscip-go gomod github.com/golang/go/src go1.25 testing/common#Errorf().("unexpected result: %s", cmpscip-go gomod github.com/google/go-cmp v0.7.0 `github.com/google/go-cmp/cmp`/.Diffscip-go gomod github.com/google/go-cmp v0.7.0 `github.com/google/go-cmp/cmp`/Diff().(exp, result)) |
| 147 | } |
| 148 | }) |
| 149 | t.Runscip-go gomod github.com/golang/go/src go1.25 testing/T#Run().("ternary returns number", func(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) { |
| 150 | result, count, err := daselscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3`/.Selectscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3`/Select().(t.Contextscip-go gomod github.com/golang/go/src go1.25 testing/common#Context().(), nil, `true ? 42 : 0`) |
| 151 | if err != nil { |
| 152 | t.Fatalfscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatalf().("unexpected error: %v", err) |
| 153 | } |
| 154 | if count != 1 { |
| 155 | t.Errorfscip-go gomod github.com/golang/go/src go1.25 testing/common#Errorf().("unexpected count: %d", count) |
| 156 | } |
| 157 | exp := []any{int64(42)} |
| 158 | if !cmpscip-go gomod github.com/google/go-cmp v0.7.0 `github.com/google/go-cmp/cmp`/.Equalscip-go gomod github.com/google/go-cmp v0.7.0 `github.com/google/go-cmp/cmp`/Equal().(exp, result) { |
| 159 | t.Errorfscip-go gomod github.com/golang/go/src go1.25 testing/common#Errorf().("unexpected result: %s", cmpscip-go gomod github.com/google/go-cmp v0.7.0 `github.com/google/go-cmp/cmp`/.Diffscip-go gomod github.com/google/go-cmp v0.7.0 `github.com/google/go-cmp/cmp`/Diff().(exp, result)) |
| 160 | } |
| 161 | }) |
| 162 | t.Runscip-go gomod github.com/golang/go/src go1.25 testing/T#Run().("ternary with arithmetic", func(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) { |
| 163 | result, count, err := daselscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3`/.Selectscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3`/Select().(t.Contextscip-go gomod github.com/golang/go/src go1.25 testing/common#Context().(), nil, `true ? 1 + 2 : 3 + 4`) |
| 164 | if err != nil { |
| 165 | t.Fatalfscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatalf().("unexpected error: %v", err) |
| 166 | } |
| 167 | if count != 1 { |
| 168 | t.Errorfscip-go gomod github.com/golang/go/src go1.25 testing/common#Errorf().("unexpected count: %d", count) |
| 169 | } |
| 170 | exp := []any{int64(3)} |
| 171 | if !cmpscip-go gomod github.com/google/go-cmp v0.7.0 `github.com/google/go-cmp/cmp`/.Equalscip-go gomod github.com/google/go-cmp v0.7.0 `github.com/google/go-cmp/cmp`/Equal().(exp, result) { |
| 172 | t.Errorfscip-go gomod github.com/golang/go/src go1.25 testing/common#Errorf().("unexpected result: %s", cmpscip-go gomod github.com/google/go-cmp v0.7.0 `github.com/google/go-cmp/cmp`/.Diffscip-go gomod github.com/google/go-cmp v0.7.0 `github.com/google/go-cmp/cmp`/Diff().(exp, result)) |
| 173 | } |
| 174 | }) |
| 175 | t.Runscip-go gomod github.com/golang/go/src go1.25 testing/T#Run().("ternary with property lookup", func(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) { |
| 176 | inputData := map[string]any{"active": true, "name": "Alice"} |
| 177 | result, count, err := daselscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3`/.Selectscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3`/Select().(t.Contextscip-go gomod github.com/golang/go/src go1.25 testing/common#Context().(), inputData, `active ? name : "unknown"`) |
| 178 | if err != nil { |
| 179 | t.Fatalfscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatalf().("unexpected error: %v", err) |
| 180 | } |
| 181 | if count != 1 { |
| 182 | t.Errorfscip-go gomod github.com/golang/go/src go1.25 testing/common#Errorf().("unexpected count: %d", count) |
| 183 | } |
| 184 | exp := []any{"Alice"} |
| 185 | if !cmpscip-go gomod github.com/google/go-cmp v0.7.0 `github.com/google/go-cmp/cmp`/.Equalscip-go gomod github.com/google/go-cmp v0.7.0 `github.com/google/go-cmp/cmp`/Equal().(exp, result) { |
| 186 | t.Errorfscip-go gomod github.com/golang/go/src go1.25 testing/common#Errorf().("unexpected result: %s", cmpscip-go gomod github.com/google/go-cmp v0.7.0 `github.com/google/go-cmp/cmp`/.Diffscip-go gomod github.com/google/go-cmp v0.7.0 `github.com/google/go-cmp/cmp`/Diff().(exp, result)) |
| 187 | } |
| 188 | }) |
| 189 | t.Runscip-go gomod github.com/golang/go/src go1.25 testing/T#Run().("ternary in map", func(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) { |
| 190 | inputData := map[string]any{ |
| 191 | "items": []any{ |
| 192 | map[string]any{"val": 10}, |
| 193 | map[string]any{"val": 3}, |
| 194 | map[string]any{"val": 7}, |
| 195 | }, |
| 196 | } |
| 197 | result, count, err := daselscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3`/.Selectscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3`/Select().(t.Contextscip-go gomod github.com/golang/go/src go1.25 testing/common#Context().(), inputData, `items.map(val >= 5 ? "big" : "small")...`) |
| 198 | if err != nil { |
| 199 | t.Fatalfscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatalf().("unexpected error: %v", err) |
| 200 | } |
| 201 | if count != 3 { |
| 202 | t.Errorfscip-go gomod github.com/golang/go/src go1.25 testing/common#Errorf().("unexpected count: %d", count) |
| 203 | } |
| 204 | exp := []any{"big", "small", "big"} |
| 205 | if !cmpscip-go gomod github.com/google/go-cmp v0.7.0 `github.com/google/go-cmp/cmp`/.Equalscip-go gomod github.com/google/go-cmp v0.7.0 `github.com/google/go-cmp/cmp`/Equal().(exp, result) { |
| 206 | t.Errorfscip-go gomod github.com/golang/go/src go1.25 testing/common#Errorf().("unexpected result: %s", cmpscip-go gomod github.com/google/go-cmp v0.7.0 `github.com/google/go-cmp/cmp`/.Diffscip-go gomod github.com/google/go-cmp v0.7.0 `github.com/google/go-cmp/cmp`/Diff().(exp, result)) |
| 207 | } |
| 208 | }) |
| 209 | t.Runscip-go gomod github.com/golang/go/src go1.25 testing/T#Run().("ternary with logical operators", func(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) { |
| 210 | inputData := map[string]any{"a": 5, "b": 10} |
| 211 | result, count, err := daselscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3`/.Selectscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3`/Select().(t.Contextscip-go gomod github.com/golang/go/src go1.25 testing/common#Context().(), inputData, `a > 1 && b > 5 ? "both" : "nope"`) |
| 212 | if err != nil { |
| 213 | t.Fatalfscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatalf().("unexpected error: %v", err) |
| 214 | } |
| 215 | if count != 1 { |
| 216 | t.Errorfscip-go gomod github.com/golang/go/src go1.25 testing/common#Errorf().("unexpected count: %d", count) |
| 217 | } |
| 218 | exp := []any{"both"} |
| 219 | if !cmpscip-go gomod github.com/google/go-cmp v0.7.0 `github.com/google/go-cmp/cmp`/.Equalscip-go gomod github.com/google/go-cmp v0.7.0 `github.com/google/go-cmp/cmp`/Equal().(exp, result) { |
| 220 | t.Errorfscip-go gomod github.com/golang/go/src go1.25 testing/common#Errorf().("unexpected result: %s", cmpscip-go gomod github.com/google/go-cmp v0.7.0 `github.com/google/go-cmp/cmp`/.Diffscip-go gomod github.com/google/go-cmp v0.7.0 `github.com/google/go-cmp/cmp`/Diff().(exp, result)) |
| 221 | } |
| 222 | }) |
| 223 | } |
| 224 | |
| 225 | func TestModifyscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3_test`/TestModify().(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) { |
| 226 | t.Runscip-go gomod github.com/golang/go/src go1.25 testing/T#Run().("index", func(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) { |
| 227 | t.Runscip-go gomod github.com/golang/go/src go1.25 testing/T#Run().("int over int", modifyTestCasescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3_test`/modifyTestCase#{ |
| 228 | selectorscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3_test`/modifyTestCase#selector.: "$this[1]", |
| 229 | inscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3_test`/modifyTestCase#in.: []int{1, 2, 3}, |
| 230 | valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3_test`/modifyTestCase#value.: 4, |
| 231 | expscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3_test`/modifyTestCase#exp.: []int{1, 4, 3}, |
| 232 | countscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3_test`/modifyTestCase#count.: 1, |
| 233 | }.runscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3_test`/modifyTestCase#run().) |
| 234 | t.Runscip-go gomod github.com/golang/go/src go1.25 testing/T#Run().("string over int", modifyTestCasescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3_test`/modifyTestCase#{ |
| 235 | selectorscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3_test`/modifyTestCase#selector.: "$this[1]", |
| 236 | inscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3_test`/modifyTestCase#in.: []any{1, 2, 3}, |
| 237 | valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3_test`/modifyTestCase#value.: "4", |
| 238 | expscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3_test`/modifyTestCase#exp.: []any{1, "4", 3}, |
| 239 | countscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3_test`/modifyTestCase#count.: 1, |
| 240 | }.runscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3_test`/modifyTestCase#run().) |
| 241 | }) |
| 242 | } |