@@ -338,19 +338,24 @@ func TestSendMessage(t *testing.T) {
338338 for _ , tt := range tests {
339339 t .Run (tt .name , func (t * testing.T ) {
340340 tempFiles := []string {}
341- for _ , filePath := range tt .files {
342- if _ , err := os .Stat (filePath ); os .IsNotExist (err ) {
343- tmpFile , err := os .CreateTemp ("" , "test-*.txt" )
344- if err == nil {
345- if _ , err := tmpFile .WriteString ("test content" ); err != nil {
346- t .Fatalf ("Failed to write to temp file: %v" , err )
341+ // Skip creating temp files for "file not found" test case
342+ if tt .name != "file not found" {
343+ for _ , filePath := range tt .files {
344+ if _ , err := os .Stat (filePath ); os .IsNotExist (err ) {
345+ tmpFile , err := os .CreateTemp ("" , "test-*.txt" )
346+ if err == nil {
347+ if _ , err := tmpFile .WriteString ("test content" ); err != nil {
348+ t .Fatalf ("Failed to write to temp file: %v" , err )
349+ }
350+ tmpFile .Close ()
351+ tempFiles = append (tempFiles , tmpFile .Name ())
347352 }
348- tmpFile . Close ()
349- tempFiles = append (tempFiles , tmpFile . Name () )
353+ } else {
354+ tempFiles = append (tempFiles , filePath )
350355 }
351- } else {
352- tempFiles = append (tempFiles , filePath )
353356 }
357+ } else {
358+ tempFiles = tt .files
354359 }
355360
356361 mock := & client.MockClient {
@@ -368,8 +373,8 @@ func TestSendMessage(t *testing.T) {
368373 if _ , ok := bodyMap ["parts" ]; ! ok {
369374 t .Error ("Expected 'parts' in request body" )
370375 }
371- if bodyMap ["noReply" ] != tt .noReply {
372- t .Errorf ("Expected noReply=%v, got %v" , tt .noReply , bodyMap [ "noReply" ] )
376+ if noReplyVal , ok := bodyMap ["noReply" ].( bool ); ok && noReplyVal != tt .noReply {
377+ t .Errorf ("Expected noReply=%v, got %v" , tt .noReply , noReplyVal )
373378 }
374379
375380 return tt .mockResp , tt .mockErr
0 commit comments