MCPcopy Create free account
hub / github.com/imgproxy/imgproxy / TestParseExistingFile

Function TestParseExistingFile

env/types_test.go:678–711  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

676}
677
678func 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}

Callers

nothing calls this directly

Calls 6

PathMethod · 0.95
NewTestDataProviderFunction · 0.92
ExistingFilePathFunction · 0.92
RunMethod · 0.80
ParseMethod · 0.80
ErrorMethod · 0.65

Tested by

no test coverage detected