Initial release

This commit is contained in:
2026-03-12 22:13:57 +00:00
commit 6c067287d7
21 changed files with 2458 additions and 0 deletions
+76
View File
@@ -0,0 +1,76 @@
package sonarr
import (
"os"
"testing"
)
func testClient(t *testing.T) *Client {
t.Helper()
url := os.Getenv("SONARR_URL")
key := os.Getenv("SONARR_API_KEY")
if url == "" || key == "" {
t.Skip("SONARR_URL and SONARR_API_KEY not set")
}
return NewClient(url, key, true)
}
func TestList(t *testing.T) {
c := testClient(t)
series, err := c.List()
if err != nil {
t.Fatalf("List: %v", err)
}
if len(series) == 0 {
t.Fatal("List returned no series")
}
s := series[0]
if s.Title == "" {
t.Error("first series has no title")
}
if s.TvdbID == 0 {
t.Error("first series has no TVDB ID")
}
}
func TestLookup(t *testing.T) {
c := testClient(t)
results, err := c.Lookup("Breaking Bad")
if err != nil {
t.Fatalf("Lookup: %v", err)
}
if len(results) == 0 {
t.Fatal("Lookup returned no results")
}
if results[0].Title == "" {
t.Error("first result has no title")
}
}
func TestQualityProfiles(t *testing.T) {
c := testClient(t)
profiles, err := c.QualityProfiles()
if err != nil {
t.Fatalf("QualityProfiles: %v", err)
}
if len(profiles) == 0 {
t.Fatal("no quality profiles returned")
}
if profiles[0].Name == "" {
t.Error("first profile has no name")
}
}
func TestRootFolders(t *testing.T) {
c := testClient(t)
folders, err := c.RootFolders()
if err != nil {
t.Fatalf("RootFolders: %v", err)
}
if len(folders) == 0 {
t.Fatal("no root folders returned")
}
if folders[0].Path == "" {
t.Error("first folder has no path")
}
}