(t *testing.T)
| 676 | } |
| 677 | |
| 678 | func TestParseExistingFile(t *testing.T) { |
| 679 | d := testutil.NewTestDataProvider(func() *testing.T { return t }) |
| 680 | |
| 681 | tests := []struct { |
| 682 | input string |
| 683 | want string |
| 684 | wantErr bool |
| 685 | errSubstr string |
| 686 | }{ |
| 687 | {input: "", want: ""}, |
| 688 | {input: d.Path("test1.jpg"), want: d.Path("test1.jpg")}, |
| 689 | {input: d.Path("nonexistent.jpg"), wantErr: true, errSubstr: "no such file"}, |
| 690 | } |
| 691 | |
| 692 | for _, tt := range tests { |
| 693 | t.Run(tt.input, func(t *testing.T) { |
| 694 | t.Setenv(testVar, tt.input) |
| 695 | desc := env.ExistingFilePath(testVar) |
| 696 | |
| 697 | var result string |
| 698 | err := desc.Parse(&result) |
| 699 | |
| 700 | if tt.wantErr { |
| 701 | require.Error(t, err) |
| 702 | if tt.errSubstr != "" { |
| 703 | assert.Contains(t, err.Error(), tt.errSubstr) |
| 704 | } |
| 705 | } else { |
| 706 | require.NoError(t, err) |
| 707 | assert.Equal(t, tt.want, result) |
| 708 | } |
| 709 | }) |
| 710 | } |
| 711 | } |
nothing calls this directly
no test coverage detected