MCPcopy Index your code
hub / github.com/go-openapi/jsonpointer / TestDashToken_SetErrors

Function TestDashToken_SetErrors

dash_token_test.go:174–195  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

172}
173
174func TestDashToken_SetErrors(t *testing.T) {
175 t.Parallel()
176
177 t.Run("intermediate dash is rejected", func(t *testing.T) {
178 doc := map[string]any{"arr": []any{1, 2}}
179 p, err := New("/arr/-/x")
180 require.NoError(t, err)
181
182 _, err = p.Set(doc, 3)
183 require.Error(t, err)
184 require.ErrorIs(t, err, ErrDashToken)
185 })
186
187 t.Run("append with wrong element type fails", func(t *testing.T) {
188 doc := map[string]any{"arr": []int{1, 2}}
189 p, err := New("/arr/-")
190 require.NoError(t, err)
191
192 _, err = p.Set(doc, "not-an-int")
193 require.Error(t, err)
194 })
195}
196
197// dashSetter captures whatever token JSONSet receives, including "-".
198type dashSetter struct {

Callers

nothing calls this directly

Calls 3

NewFunction · 0.85
SetMethod · 0.80
ErrorMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…