diff --git a/cmd/soundtouch-cli/cmd_station.go b/cmd/soundtouch-cli/cmd_station.go index d30bb1b..33cea7a 100644 --- a/cmd/soundtouch-cli/cmd_station.go +++ b/cmd/soundtouch-cli/cmd_station.go @@ -146,7 +146,7 @@ func searchSpotify(c *cli.Context) error { // Check Spotify availability checker := NewServiceAvailabilityChecker(client) if !checker.ValidateSpotifyAvailable("search Spotify content") { - return fmt.Errorf("Spotify is not available on this device") + return fmt.Errorf("spotify is not available on this device") } response, err := client.SearchSpotifyContent(sourceAccount, searchTerm) diff --git a/cmd/soundtouch-cli/common.go b/cmd/soundtouch-cli/common.go index 8206d98..efc0dfd 100644 --- a/cmd/soundtouch-cli/common.go +++ b/cmd/soundtouch-cli/common.go @@ -175,7 +175,7 @@ var httpClient = &http.Client{ func fetchTuneInMetadata(url string) (*TuneInMetadata, error) { if !strings.Contains(url, "tunein.com/radio/") { - return nil, nil + return nil, fmt.Errorf("url is not a TuneIn radio URL") } resp, err := httpClient.Get(url) diff --git a/cmd/soundtouch-cli/common_test.go b/cmd/soundtouch-cli/common_test.go index bd61a44..beeca88 100644 --- a/cmd/soundtouch-cli/common_test.go +++ b/cmd/soundtouch-cli/common_test.go @@ -7,7 +7,7 @@ import ( ) func TestFetchTuneInMetadata(t *testing.T) { - ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { html := ` diff --git a/pkg/client/navigation_test.go b/pkg/client/navigation_test.go index 63e6051..eb1965d 100644 --- a/pkg/client/navigation_test.go +++ b/pkg/client/navigation_test.go @@ -113,7 +113,7 @@ func TestClient_Navigate(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { if tt.serverStatus != 0 { w.WriteHeader(tt.serverStatus) } @@ -241,7 +241,7 @@ func TestClient_NavigateContainer(t *testing.T) { ` - server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { _, _ = w.Write([]byte(serverResponse)) })) defer server.Close() @@ -344,7 +344,7 @@ func TestClient_AddStation(t *testing.T) { w.WriteHeader(tt.serverStatus) } if tt.serverResponse != "" { - w.Write([]byte(tt.serverResponse)) + _, _ = w.Write([]byte(tt.serverResponse)) } // Verify request format @@ -457,7 +457,7 @@ func TestClient_RemoveStation(t *testing.T) { w.WriteHeader(tt.serverStatus) } if tt.serverResponse != "" { - w.Write([]byte(tt.serverResponse)) + _, _ = w.Write([]byte(tt.serverResponse)) } // Verify request format @@ -534,7 +534,7 @@ func TestClient_GetPandoraStations(t *testing.T) { t.Errorf("Expected sort dateCreated, got %s", request.Sort) } - w.Write([]byte(serverResponse)) + _, _ = w.Write([]byte(serverResponse)) })) defer server.Close() @@ -560,7 +560,7 @@ func TestClient_GetPandoraStations(t *testing.T) { // Test error case _, err = client.GetPandoraStations("") - if err == nil || !contains(err.Error(), "Pandora source account cannot be empty") { + if err == nil || !contains(err.Error(), "pandora source account cannot be empty") { t.Error("Expected error for empty source account") } } @@ -580,8 +580,8 @@ func TestClient_GetTuneInStations(t *testing.T) { ` - server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - w.Write([]byte(serverResponse)) + server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { + _, _ = w.Write([]byte(serverResponse)) })) defer server.Close() @@ -621,8 +621,8 @@ func TestClient_GetStoredMusicLibrary(t *testing.T) { ` - server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - w.Write([]byte(serverResponse)) + server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { + _, _ = w.Write([]byte(serverResponse)) })) defer server.Close() @@ -739,7 +739,7 @@ func TestClient_SearchStation(t *testing.T) { w.WriteHeader(tt.serverStatus) } if tt.serverResponse != "" { - w.Write([]byte(tt.serverResponse)) + _, _ = w.Write([]byte(tt.serverResponse)) } // Verify request format for valid requests @@ -823,7 +823,7 @@ func TestClient_SearchPandoraStations(t *testing.T) { t.Errorf("Expected searchTerm 'Taylor Swift', got %s", request.SearchTerm) } - w.Write([]byte(serverResponse)) + _, _ = w.Write([]byte(serverResponse)) })) defer server.Close() @@ -849,7 +849,7 @@ func TestClient_SearchPandoraStations(t *testing.T) { // Test error case _, err = client.SearchPandoraStations("", "test") - if err == nil || !contains(err.Error(), "Pandora source account cannot be empty") { + if err == nil || !contains(err.Error(), "pandora source account cannot be empty") { t.Error("Expected error for empty source account") } } @@ -866,8 +866,8 @@ func TestClient_SearchTuneInStations(t *testing.T) { ` - server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - w.Write([]byte(serverResponse)) + server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { + _, _ = w.Write([]byte(serverResponse)) })) defer server.Close() @@ -909,8 +909,8 @@ func TestClient_SearchSpotifyContent(t *testing.T) { ` - server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - w.Write([]byte(serverResponse)) + server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { + _, _ = w.Write([]byte(serverResponse)) })) defer server.Close() @@ -936,7 +936,7 @@ func TestClient_SearchSpotifyContent(t *testing.T) { // Test error case _, err = client.SearchSpotifyContent("", "test") - if err == nil || !contains(err.Error(), "Spotify source account cannot be empty") { + if err == nil || !contains(err.Error(), "spotify source account cannot be empty") { t.Error("Expected error for empty source account") } } diff --git a/pkg/client/navigation_xml_test.go b/pkg/client/navigation_xml_test.go index 22b9bbc..b53925c 100644 --- a/pkg/client/navigation_xml_test.go +++ b/pkg/client/navigation_xml_test.go @@ -57,11 +57,11 @@ func TestClient_NavigateXMLValidation(t *testing.T) { capturedEndpoint = r.URL.Path body := make([]byte, r.ContentLength) - r.Body.Read(body) + _, _ = r.Body.Read(body) capturedXML = string(body) // Return valid navigate response - w.Write([]byte(` + _, _ = w.Write([]byte(` 0 @@ -99,11 +99,11 @@ func TestClient_NavigateWithMenuXMLValidation(t *testing.T) { server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { body := make([]byte, r.ContentLength) - r.Body.Read(body) + _, _ = r.Body.Read(body) capturedXML = string(body) - w.Write([]byte(` - + _, _ = w.Write([]byte(` + 0 `)) @@ -174,10 +174,10 @@ func TestClient_SearchStationXMLValidation(t *testing.T) { server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { body := make([]byte, r.ContentLength) - r.Body.Read(body) + _, _ = r.Body.Read(body) capturedXML = string(body) - w.Write([]byte(` + _, _ = w.Write([]byte(` @@ -212,10 +212,10 @@ func TestClient_AddStationXMLValidation(t *testing.T) { server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { body := make([]byte, r.ContentLength) - r.Body.Read(body) + _, _ = r.Body.Read(body) capturedXML = string(body) - w.Write([]byte(`/addStation`)) + _, _ = w.Write([]byte(`/addStation`)) })) defer server.Close() @@ -252,10 +252,10 @@ func TestClient_RemoveStationXMLValidation(t *testing.T) { server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { body := make([]byte, r.ContentLength) - r.Body.Read(body) + _, _ = r.Body.Read(body) capturedXML = string(body) - w.Write([]byte(`/removeStation`)) + _, _ = w.Write([]byte(`/removeStation`)) })) defer server.Close() @@ -353,8 +353,8 @@ func TestClient_NavigationResponseParsing(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - w.Write([]byte(tt.responseXML)) + server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { + _, _ = w.Write([]byte(tt.responseXML)) })) defer server.Close() @@ -465,8 +465,8 @@ func TestClient_SearchStationResponseParsing(t *testing.T) { ` - server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - w.Write([]byte(responseXML)) + server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { + _, _ = w.Write([]byte(responseXML)) })) defer server.Close() @@ -559,7 +559,7 @@ func TestClient_NavigationHTTPHeaders(t *testing.T) { server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { capturedHeaders = r.Header - w.Write([]byte(` + _, _ = w.Write([]byte(` 0 diff --git a/pkg/client/preset_test.go b/pkg/client/preset_test.go index 73e90e6..bdd7399 100644 --- a/pkg/client/preset_test.go +++ b/pkg/client/preset_test.go @@ -117,7 +117,7 @@ func TestClient_StorePreset(t *testing.T) { w.WriteHeader(tt.serverStatus) } if tt.serverResponse != "" { - w.Write([]byte(tt.serverResponse)) + _, _ = w.Write([]byte(tt.serverResponse)) } })) defer server.Close() @@ -200,7 +200,7 @@ func TestClient_RemovePreset(t *testing.T) { w.WriteHeader(tt.serverStatus) } if tt.serverResponse != "" { - w.Write([]byte(tt.serverResponse)) + _, _ = w.Write([]byte(tt.serverResponse)) } })) defer server.Close() @@ -343,7 +343,7 @@ func TestClient_StoreCurrentAsPreset(t *testing.T) { w.WriteHeader(http.StatusOK) } if tt.nowPlayingResponse != "" { - w.Write([]byte(tt.nowPlayingResponse)) + _, _ = w.Write([]byte(tt.nowPlayingResponse)) } case "/storePreset": if tt.storePresetStatus != 0 { @@ -351,7 +351,7 @@ func TestClient_StoreCurrentAsPreset(t *testing.T) { } else { w.WriteHeader(http.StatusOK) } - w.Write([]byte(``)) + _, _ = w.Write([]byte(``)) default: w.WriteHeader(http.StatusNotFound) } @@ -386,9 +386,9 @@ func TestClient_StorePreset_XMLGeneration(t *testing.T) { var capturedXML string server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { body := make([]byte, r.ContentLength) - r.Body.Read(body) + _, _ = r.Body.Read(body) capturedXML = string(body) - w.Write([]byte(``)) + _, _ = w.Write([]byte(``)) })) defer server.Close() @@ -437,9 +437,9 @@ func TestClient_RemovePreset_XMLGeneration(t *testing.T) { var capturedXML string server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { body := make([]byte, r.ContentLength) - r.Body.Read(body) + _, _ = r.Body.Read(body) capturedXML = string(body) - w.Write([]byte(``)) + _, _ = w.Write([]byte(``)) })) defer server.Close() @@ -536,9 +536,9 @@ func TestClient_StorePreset_RealWorldScenarios(t *testing.T) { for _, scenario := range scenarios { t.Run(scenario.name, func(t *testing.T) { - server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { // Just return success for these scenario tests - w.Write([]byte(``)) + _, _ = w.Write([]byte(``)) })) defer server.Close() @@ -556,8 +556,8 @@ func TestClient_StorePreset_RealWorldScenarios(t *testing.T) { } func TestClient_PresetTimestamps(t *testing.T) { - server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - w.Write([]byte(``)) + server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { + _, _ = w.Write([]byte(``)) })) defer server.Close() diff --git a/pkg/models/serviceavailability.go b/pkg/models/serviceavailability.go index 8c87dac..641f323 100644 --- a/pkg/models/serviceavailability.go +++ b/pkg/models/serviceavailability.go @@ -25,19 +25,31 @@ type ServiceType string const ( // ServiceTypeAirPlay represents Apple AirPlay streaming service - ServiceTypeAirPlay ServiceType = "AIRPLAY" - ServiceTypeAlexa ServiceType = "ALEXA" - ServiceTypeAmazon ServiceType = "AMAZON" - ServiceTypeBluetooth ServiceType = "BLUETOOTH" - ServiceTypeBMX ServiceType = "BMX" - ServiceTypeDeezer ServiceType = "DEEZER" - ServiceTypeIHeart ServiceType = "IHEART" + ServiceTypeAirPlay ServiceType = "AIRPLAY" + // ServiceTypeAlexa represents Amazon Alexa voice assistant integration + ServiceTypeAlexa ServiceType = "ALEXA" + // ServiceTypeAmazon represents Amazon Music streaming service + ServiceTypeAmazon ServiceType = "AMAZON" + // ServiceTypeBluetooth represents Bluetooth audio connectivity + ServiceTypeBluetooth ServiceType = "BLUETOOTH" + // ServiceTypeBMX represents BMX streaming service + ServiceTypeBMX ServiceType = "BMX" + // ServiceTypeDeezer represents Deezer music streaming service + ServiceTypeDeezer ServiceType = "DEEZER" + // ServiceTypeIHeart represents iHeartRadio streaming service + ServiceTypeIHeart ServiceType = "IHEART" + // ServiceTypeLocalInternetRadio represents local internet radio stations ServiceTypeLocalInternetRadio ServiceType = "LOCAL_INTERNET_RADIO" - ServiceTypeLocalMusic ServiceType = "LOCAL_MUSIC" - ServiceTypeNotification ServiceType = "NOTIFICATION" - ServiceTypePandora ServiceType = "PANDORA" - ServiceTypeSpotify ServiceType = "SPOTIFY" - ServiceTypeTuneIn ServiceType = "TUNEIN" + // ServiceTypeLocalMusic represents local music library + ServiceTypeLocalMusic ServiceType = "LOCAL_MUSIC" + // ServiceTypeNotification represents system notifications + ServiceTypeNotification ServiceType = "NOTIFICATION" + // ServiceTypePandora represents Pandora music streaming service + ServiceTypePandora ServiceType = "PANDORA" + // ServiceTypeSpotify represents Spotify music streaming service + ServiceTypeSpotify ServiceType = "SPOTIFY" + // ServiceTypeTuneIn represents TuneIn internet radio service + ServiceTypeTuneIn ServiceType = "TUNEIN" ) // GetReason returns the reason why a service is unavailable (if any) diff --git a/pkg/models/serviceavailability_test.go b/pkg/models/serviceavailability_test.go index 9227710..71ca51e 100644 --- a/pkg/models/serviceavailability_test.go +++ b/pkg/models/serviceavailability_test.go @@ -32,6 +32,7 @@ func TestServiceAvailability_UnmarshalXML(t *testing.T) { `, validate: func(t *testing.T, sa *ServiceAvailability) { + t.Helper() if sa.Services == nil { t.Fatal("services should not be nil") } @@ -71,6 +72,7 @@ func TestServiceAvailability_UnmarshalXML(t *testing.T) { `, validate: func(t *testing.T, sa *ServiceAvailability) { + t.Helper() if sa.Services == nil { t.Fatal("services should not be nil") } @@ -87,6 +89,7 @@ func TestServiceAvailability_UnmarshalXML(t *testing.T) { `, validate: func(t *testing.T, sa *ServiceAvailability) { + t.Helper() if sa.Services == nil { t.Fatal("services should not be nil") }