Debian Codegraph @

execution/execute_error_test.go

raw symbols SCIP
1 package execution_testscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution_test`/
2
3 import (
4 "contextscip-go gomod github.com/golang/go/src go1.25 context/"
5 "stringsscip-go gomod github.com/golang/go/src go1.25 strings/"
6 "testingscip-go gomod github.com/golang/go/src go1.25 testing/"
7
8 "github.com/tomwright/dasel/v3/executionscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/"
9 "github.com/tomwright/dasel/v3/modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/"
10 )
11
12 func TestErrorsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution_test`/TestErrors().(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) {
13 t.Runscip-go gomod github.com/golang/go/src go1.25 testing/T#Run().("unknown function", 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#) {
14 in := modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.NewNullValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/NewNullValue().()
15 _, err := executionscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/.ExecuteSelectorscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/ExecuteSelector().(contextscip-go gomod github.com/golang/go/src go1.25 context/.Backgroundscip-go gomod github.com/golang/go/src go1.25 context/Background().(), `unknownFunc123()`, in, executionscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/.NewOptionsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/NewOptions().())
16 if err == nil {
17 t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().("expected error for unknown function")
18 }
19 if !stringsscip-go gomod github.com/golang/go/src go1.25 strings/.Containsscip-go gomod github.com/golang/go/src go1.25 strings/Contains().(err.Error(), "unknown function") {
20 t.Fatalfscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatalf().("unexpected error: %s", err)
21 }
22 })
23
24 t.Runscip-go gomod github.com/golang/go/src go1.25 testing/T#Run().("empty selector returns input", 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#) {
25 in := modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.NewStringValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/NewStringValue().("hello")
26 res, err := executionscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/.ExecuteSelectorscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/ExecuteSelector().(contextscip-go gomod github.com/golang/go/src go1.25 context/.Backgroundscip-go gomod github.com/golang/go/src go1.25 context/Background().(), ``, in, executionscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/.NewOptionsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/NewOptions().())
27 if err != nil {
28 t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().(err)
29 }
30 got, err := res.StringValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#StringValue().()
31 if err != nil {
32 t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().(err)
33 }
34 if got != "hello" {
35 t.Errorfscip-go gomod github.com/golang/go/src go1.25 testing/common#Errorf().("expected 'hello', got %s", got)
36 }
37 })
38
39 t.Runscip-go gomod github.com/golang/go/src go1.25 testing/T#Run().("filter on non-array", 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#) {
40 in := modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.NewStringValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/NewStringValue().("not a slice")
41 _, err := executionscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/.ExecuteSelectorscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/ExecuteSelector().(contextscip-go gomod github.com/golang/go/src go1.25 context/.Backgroundscip-go gomod github.com/golang/go/src go1.25 context/Background().(), `filter($this == "x")`, in, executionscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/.NewOptionsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/NewOptions().())
42 if err == nil {
43 t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().("expected error for filter on non-array")
44 }
45 })
46
47 t.Runscip-go gomod github.com/golang/go/src go1.25 testing/T#Run().("each on non-array", 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#) {
48 in := modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.NewStringValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/NewStringValue().("not a slice")
49 _, err := executionscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/.ExecuteSelectorscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/ExecuteSelector().(contextscip-go gomod github.com/golang/go/src go1.25 context/.Backgroundscip-go gomod github.com/golang/go/src go1.25 context/Background().(), `each($this = $this)`, in, executionscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/.NewOptionsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/NewOptions().())
50 if err == nil {
51 t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().("expected error for each on non-array")
52 }
53 })
54
55 t.Runscip-go gomod github.com/golang/go/src go1.25 testing/T#Run().("sortBy on non-array", 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#) {
56 in := modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.NewStringValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/NewStringValue().("not a slice")
57 _, err := executionscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/.ExecuteSelectorscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/ExecuteSelector().(contextscip-go gomod github.com/golang/go/src go1.25 context/.Backgroundscip-go gomod github.com/golang/go/src go1.25 context/Background().(), `sortBy($this)`, in, executionscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/.NewOptionsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/NewOptions().())
58 if err == nil {
59 t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().("expected error for sortBy on non-array")
60 }
61 })
62
63 t.Runscip-go gomod github.com/golang/go/src go1.25 testing/T#Run().("map on non-array", 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#) {
64 in := modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.NewStringValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/NewStringValue().("not a slice")
65 _, err := executionscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/.ExecuteSelectorscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/ExecuteSelector().(contextscip-go gomod github.com/golang/go/src go1.25 context/.Backgroundscip-go gomod github.com/golang/go/src go1.25 context/Background().(), `map($this)`, in, executionscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/.NewOptionsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/NewOptions().())
66 if err == nil {
67 t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().("expected error for map on non-array")
68 }
69 })
70
71 t.Runscip-go gomod github.com/golang/go/src go1.25 testing/T#Run().("spread on non-spreadable", 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#) {
72 in := modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.NewIntValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/NewIntValue().(42)
73 _, err := executionscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/.ExecuteSelectorscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/ExecuteSelector().(contextscip-go gomod github.com/golang/go/src go1.25 context/.Backgroundscip-go gomod github.com/golang/go/src go1.25 context/Background().(), `$this...`, in, executionscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/.NewOptionsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/NewOptions().())
74 if err == nil {
75 t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().("expected error for spread on int")
76 }
77 })
78
79 t.Runscip-go gomod github.com/golang/go/src go1.25 testing/T#Run().("all on non-array", 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#) {
80 in := modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.NewStringValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/NewStringValue().("not a slice")
81 _, err := executionscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/.ExecuteSelectorscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/ExecuteSelector().(contextscip-go gomod github.com/golang/go/src go1.25 context/.Backgroundscip-go gomod github.com/golang/go/src go1.25 context/Background().(), `all($this == "x")`, in, executionscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/.NewOptionsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/NewOptions().())
82 if err == nil {
83 t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().("expected error for all on non-array")
84 }
85 })
86
87 t.Runscip-go gomod github.com/golang/go/src go1.25 testing/T#Run().("any on non-array", 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#) {
88 in := modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.NewStringValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/NewStringValue().("not a slice")
89 _, err := executionscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/.ExecuteSelectorscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/ExecuteSelector().(contextscip-go gomod github.com/golang/go/src go1.25 context/.Backgroundscip-go gomod github.com/golang/go/src go1.25 context/Background().(), `any($this == "x")`, in, executionscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/.NewOptionsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/NewOptions().())
90 if err == nil {
91 t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().("expected error for any on non-array")
92 }
93 })
94
95 t.Runscip-go gomod github.com/golang/go/src go1.25 testing/T#Run().("count on non-array", 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 in := modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.NewStringValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/NewStringValue().("not a slice")
97 _, err := executionscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/.ExecuteSelectorscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/ExecuteSelector().(contextscip-go gomod github.com/golang/go/src go1.25 context/.Backgroundscip-go gomod github.com/golang/go/src go1.25 context/Background().(), `count($this == "x")`, in, executionscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/.NewOptionsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/execution`/NewOptions().())
98 if err == nil {
99 t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().("expected error for count on non-array")
100 }
101 })
102 }