MCPcopy
hub / github.com/pocketbase/pocketbase / TestFilterDataBuildExprWithLimit

Function TestFilterDataBuildExprWithLimit

tools/search/filter_test.go:249–276  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

247}
248
249func TestFilterDataBuildExprWithLimit(t *testing.T) {
250 resolver := search.NewSimpleFieldResolver(`^\w+$`)
251
252 scenarios := []struct {
253 limit int
254 filter search.FilterData
255 expectError bool
256 }{
257 {1, "1 = 1", false},
258 {0, "1 = 1", true}, // new cache entry should be created
259 {2, "1 = 1 || 1 = 1", false},
260 {1, "1 = 1 || 1 = 1", true},
261 {3, "1 = 1 || 1 = 1", false},
262 {6, "(1=1 || 1=1) && (1=1 || (1=1 || 1=1)) && (1=1)", false},
263 {5, "(1=1 || 1=1) && (1=1 || (1=1 || 1=1)) && (1=1)", true},
264 }
265
266 for i, s := range scenarios {
267 t.Run(fmt.Sprintf("limit_%d:%d", i, s.limit), func(t *testing.T) {
268 _, err := s.filter.BuildExprWithLimit(resolver, s.limit)
269
270 hasErr := err != nil
271 if hasErr != s.expectError {
272 t.Fatalf("Expected hasErr %v, got %v", s.expectError, hasErr)
273 }
274 })
275 }
276}
277
278func TestLikeParamsWrapping(t *testing.T) {
279 // create a dummy db

Callers

nothing calls this directly

Calls 3

NewSimpleFieldResolverFunction · 0.92
BuildExprWithLimitMethod · 0.80
RunMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…