Skip to content

Commit 1e91217

Browse files
authored
test: cover CreateFile request builder failure (sashabaranov#1041)
1 parent 8665ad7 commit 1e91217

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

files_test.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,3 +121,20 @@ func TestFileUploadWithNonExistentPath(t *testing.T) {
121121
_, err := client.CreateFile(ctx, req)
122122
checks.ErrorIs(t, err, os.ErrNotExist, "CreateFile should return error if file does not exist")
123123
}
124+
func TestCreateFileRequestBuilderFailure(t *testing.T) {
125+
config := DefaultConfig("")
126+
config.BaseURL = ""
127+
client := NewClientWithConfig(config)
128+
client.requestBuilder = &failingRequestBuilder{}
129+
130+
client.createFormBuilder = func(io.Writer) utils.FormBuilder {
131+
return &mockFormBuilder{
132+
mockWriteField: func(string, string) error { return nil },
133+
mockCreateFormFile: func(string, *os.File) error { return nil },
134+
mockClose: func() error { return nil },
135+
}
136+
}
137+
138+
_, err := client.CreateFile(context.Background(), FileRequest{FilePath: "client.go"})
139+
checks.ErrorIs(t, err, errTestRequestBuilderFailed, "CreateFile should return error if request builder fails")
140+
}

0 commit comments

Comments
 (0)