Skip to content

Commit 96742f9

Browse files
committed
fix: add error checks in add_test.go for golangci-lint
1 parent d1b7a1c commit 96742f9

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

oho/cmd/add/add_test.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,9 @@ func TestCreateSession(t *testing.T) {
207207

208208
bodyBytes, _ := json.Marshal(body)
209209
var bodyMap map[string]interface{}
210-
json.Unmarshal(bodyBytes, &bodyMap)
210+
if err := json.Unmarshal(bodyBytes, &bodyMap); err != nil {
211+
t.Fatalf("Failed to unmarshal request body: %v", err)
212+
}
211213

212214
if tt.title != "" {
213215
if _, ok := bodyMap["title"]; !ok {
@@ -340,7 +342,9 @@ func TestSendMessage(t *testing.T) {
340342
if _, err := os.Stat(filePath); os.IsNotExist(err) {
341343
tmpFile, err := os.CreateTemp("", "test-*.txt")
342344
if err == nil {
343-
tmpFile.WriteString("test content")
345+
if _, err := tmpFile.WriteString("test content"); err != nil {
346+
t.Fatalf("Failed to write to temp file: %v", err)
347+
}
344348
tmpFile.Close()
345349
tempFiles = append(tempFiles, tmpFile.Name())
346350
}
@@ -357,7 +361,9 @@ func TestSendMessage(t *testing.T) {
357361

358362
bodyBytes, _ := json.Marshal(body)
359363
var bodyMap map[string]interface{}
360-
json.Unmarshal(bodyBytes, &bodyMap)
364+
if err := json.Unmarshal(bodyBytes, &bodyMap); err != nil {
365+
t.Fatalf("Failed to unmarshal request body: %v", err)
366+
}
361367

362368
if _, ok := bodyMap["parts"]; !ok {
363369
t.Error("Expected 'parts' in request body")

0 commit comments

Comments
 (0)