Skip to content

Commit d0cfb0a

Browse files
committed
test: fix some issue form golangci-lint
1 parent 76ae485 commit d0cfb0a

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

internal/error_accumulator_test.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ import (
88
)
99

1010
func TestDefaultErrorAccumulator_WriteMultiple(t *testing.T) {
11-
ea := openai.NewErrorAccumulator().(*openai.DefaultErrorAccumulator)
12-
11+
ea, ok := openai.NewErrorAccumulator().(*openai.DefaultErrorAccumulator)
12+
if !ok {
13+
t.Fatal("type assertion to *DefaultErrorAccumulator failed")
14+
}
1315
checks.NoError(t, ea.Write([]byte("{\"error\": \"test1\"}")))
1416
checks.NoError(t, ea.Write([]byte("{\"error\": \"test2\"}")))
1517

@@ -20,8 +22,10 @@ func TestDefaultErrorAccumulator_WriteMultiple(t *testing.T) {
2022
}
2123

2224
func TestDefaultErrorAccumulator_EmptyBuffer(t *testing.T) {
23-
ea := openai.NewErrorAccumulator().(*openai.DefaultErrorAccumulator)
24-
25+
ea, ok := openai.NewErrorAccumulator().(*openai.DefaultErrorAccumulator)
26+
if !ok {
27+
t.Fatal("type assertion to *DefaultErrorAccumulator failed")
28+
}
2529
if len(ea.Bytes()) != 0 {
2630
t.Fatal("Buffer should be empty initially")
2731
}

internal/form_builder_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ func TestMultiPartFormUploads(t *testing.T) {
105105
t.Run("LargeFileConcurrent", func(t *testing.T) {
106106
bigFile, _ := os.CreateTemp(t.TempDir(), "*.bin")
107107
defer bigFile.Close()
108-
bigFile.Write(make([]byte, 1024*1024*5)) // 5MB test file
109-
108+
_, err := bigFile.Write(make([]byte, 1024*1024*5)) // 5MB test file
109+
checks.NoError(t, err, "Failed to write large file data")
110110
checks.NoError(t, builder.CreateFormFile("bigfile", bigFile), "Large file upload failed")
111111
checks.NoError(t, builder.WriteField("note", "large file test"), "Field write failed")
112112
})
@@ -148,7 +148,7 @@ func TestCreateFormFileReader(t *testing.T) {
148148

149149
type failingReader struct{}
150150

151-
func (r *failingReader) Read(p []byte) (int, error) {
151+
func (r *failingReader) Read(_ []byte) (int, error) {
152152
return 0, errors.New("mock read error")
153153
}
154154

0 commit comments

Comments
 (0)