(c *C)
| 2434 | } |
| 2435 | |
| 2436 | func (s *WorktreeSuite) TestGrep(c *C) { |
| 2437 | cases := []struct { |
| 2438 | name string |
| 2439 | options GrepOptions |
| 2440 | wantResult []GrepResult |
| 2441 | dontWantResult []GrepResult |
| 2442 | wantError error |
| 2443 | }{ |
| 2444 | { |
| 2445 | name: "basic word match", |
| 2446 | options: GrepOptions{ |
| 2447 | Patterns: []*regexp.Regexp{regexp.MustCompile("import")}, |
| 2448 | }, |
| 2449 | wantResult: []GrepResult{ |
| 2450 | { |
| 2451 | FileName: "go/example.go", |
| 2452 | LineNumber: 3, |
| 2453 | Content: "import (", |
| 2454 | TreeName: "6ecf0ef2c2dffb796033e5a02219af86ec6584e5", |
| 2455 | }, |
| 2456 | { |
| 2457 | FileName: "vendor/foo.go", |
| 2458 | LineNumber: 3, |
| 2459 | Content: "import \"fmt\"", |
| 2460 | TreeName: "6ecf0ef2c2dffb796033e5a02219af86ec6584e5", |
| 2461 | }, |
| 2462 | }, |
| 2463 | }, { |
| 2464 | name: "case insensitive match", |
| 2465 | options: GrepOptions{ |
| 2466 | Patterns: []*regexp.Regexp{regexp.MustCompile(`(?i)IMport`)}, |
| 2467 | }, |
| 2468 | wantResult: []GrepResult{ |
| 2469 | { |
| 2470 | FileName: "go/example.go", |
| 2471 | LineNumber: 3, |
| 2472 | Content: "import (", |
| 2473 | TreeName: "6ecf0ef2c2dffb796033e5a02219af86ec6584e5", |
| 2474 | }, |
| 2475 | { |
| 2476 | FileName: "vendor/foo.go", |
| 2477 | LineNumber: 3, |
| 2478 | Content: "import \"fmt\"", |
| 2479 | TreeName: "6ecf0ef2c2dffb796033e5a02219af86ec6584e5", |
| 2480 | }, |
| 2481 | }, |
| 2482 | }, { |
| 2483 | name: "invert match", |
| 2484 | options: GrepOptions{ |
| 2485 | Patterns: []*regexp.Regexp{regexp.MustCompile("import")}, |
| 2486 | InvertMatch: true, |
| 2487 | }, |
| 2488 | dontWantResult: []GrepResult{ |
| 2489 | { |
| 2490 | FileName: "go/example.go", |
| 2491 | LineNumber: 3, |
| 2492 | Content: "import (", |
| 2493 | TreeName: "6ecf0ef2c2dffb796033e5a02219af86ec6584e5", |
nothing calls this directly
no test coverage detected