@@ -332,7 +332,8 @@ func TestDownloadAudio(t *testing.T) {
332332
333333 // Use a single server for both API and download
334334 server := httptest .NewServer (http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
335- if r .URL .Path == "/recordings/rec-123" {
335+ switch r .URL .Path {
336+ case "/recordings/rec-123" :
336337 w .Header ().Set ("Content-Type" , "application/json" )
337338 recording := Recording {
338339 ID : "rec-123" ,
@@ -341,15 +342,15 @@ func TestDownloadAudio(t *testing.T) {
341342 },
342343 }
343344 _ = json .NewEncoder (w ).Encode (recording )
344- } else if r . URL . Path == "/download/audio.mp3" {
345+ case "/download/audio.mp3" :
345346 if r .Header .Get ("Authorization" ) != "Bearer test-token" {
346347 t .Errorf ("Expected auth header on download request" )
347348 }
348349 w .Header ().Set ("Content-Type" , "audio/mpeg" )
349350 w .Header ().Set ("Content-Disposition" , `attachment; filename="audio.mp3"` )
350351 w .WriteHeader (http .StatusOK )
351352 _ , _ = w .Write (audioContent )
352- } else {
353+ default :
353354 t .Errorf ("Unexpected path: %s" , r .URL .Path )
354355 w .WriteHeader (http .StatusNotFound )
355356 }
@@ -384,7 +385,8 @@ func TestDownloadRecording(t *testing.T) {
384385 videoContent := []byte ("fake mp4 video content" )
385386
386387 server := httptest .NewServer (http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
387- if r .URL .Path == "/recordings/rec-123" {
388+ switch r .URL .Path {
389+ case "/recordings/rec-123" :
388390 w .Header ().Set ("Content-Type" , "application/json" )
389391 recording := Recording {
390392 ID : "rec-123" ,
@@ -393,11 +395,11 @@ func TestDownloadRecording(t *testing.T) {
393395 },
394396 }
395397 _ = json .NewEncoder (w ).Encode (recording )
396- } else if r . URL . Path == "/download/video.mp4" {
398+ case "/download/video.mp4" :
397399 w .Header ().Set ("Content-Type" , "video/mp4" )
398400 w .WriteHeader (http .StatusOK )
399401 _ , _ = w .Write (videoContent )
400- } else {
402+ default :
401403 w .WriteHeader (http .StatusNotFound )
402404 }
403405 }))
@@ -431,7 +433,8 @@ func TestDownloadTranscript(t *testing.T) {
431433 transcriptContent := []byte ("Speaker 1: Hello\n Speaker 2: Hi there" )
432434
433435 server := httptest .NewServer (http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
434- if r .URL .Path == "/recordings/rec-123" {
436+ switch r .URL .Path {
437+ case "/recordings/rec-123" :
435438 w .Header ().Set ("Content-Type" , "application/json" )
436439 recording := Recording {
437440 ID : "rec-123" ,
@@ -440,13 +443,13 @@ func TestDownloadTranscript(t *testing.T) {
440443 },
441444 }
442445 _ = json .NewEncoder (w ).Encode (recording )
443- } else if r . URL . Path == "/download/transcript.txt" {
446+ case "/download/transcript.txt" :
444447 w .Header ().Set ("Content-Type" , "text/plain" )
445448 w .WriteHeader (http .StatusOK )
446449 if _ , err := w .Write (transcriptContent ); err != nil {
447450 t .Logf ("Failed to write response: %v" , err )
448451 }
449- } else {
452+ default :
450453 w .WriteHeader (http .StatusNotFound )
451454 }
452455 }))
0 commit comments