(t *testing.T)
| 635 | } |
| 636 | |
| 637 | func TestRegexpFromPattern(t *testing.T) { |
| 638 | tests := []struct { |
| 639 | pattern string |
| 640 | shouldMatch []string |
| 641 | shouldntMatch []string |
| 642 | }{ |
| 643 | { |
| 644 | pattern: "test.jpg", |
| 645 | shouldMatch: []string{"test.jpg"}, |
| 646 | shouldntMatch: []string{"test2.jpg"}, |
| 647 | }, |
| 648 | { |
| 649 | pattern: "*.jpg", |
| 650 | shouldMatch: []string{"image.jpg", "photo123.jpg"}, |
| 651 | shouldntMatch: []string{"dir/image.jpg"}, |
| 652 | }, |
| 653 | { |
| 654 | pattern: "*-*-*.jpg", |
| 655 | shouldMatch: []string{"img-01-thumb.jpg"}, |
| 656 | shouldntMatch: []string{"img-01.jpg"}, |
| 657 | }, |
| 658 | { |
| 659 | pattern: "prefix*", |
| 660 | shouldMatch: []string{"prefix123"}, |
| 661 | shouldntMatch: []string{"notprefix"}, |
| 662 | }, |
| 663 | } |
| 664 | |
| 665 | for _, tt := range tests { |
| 666 | t.Run(tt.pattern, func(t *testing.T) { |
| 667 | re := env.RegexpFromPattern(tt.pattern) |
| 668 | for _, match := range tt.shouldMatch { |
| 669 | assert.True(t, re.MatchString(match)) |
| 670 | } |
| 671 | for _, noMatch := range tt.shouldntMatch { |
| 672 | assert.False(t, re.MatchString(noMatch)) |
| 673 | } |
| 674 | }) |
| 675 | } |
| 676 | } |
| 677 | |
| 678 | func TestParseExistingFile(t *testing.T) { |
| 679 | d := testutil.NewTestDataProvider(func() *testing.T { return t }) |
nothing calls this directly
no test coverage detected