(t *testing.T)
| 247 | } |
| 248 | |
| 249 | func 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 | |
| 278 | func TestLikeParamsWrapping(t *testing.T) { |
| 279 | // create a dummy db |
nothing calls this directly
no test coverage detected
searching dependent graphs…