0.2.55 - Remote config/Request fixes
This commit is contained in:
@@ -116,8 +116,10 @@ func (c *Client) Lookup(ctx context.Context, term string) ([]Movie, error) {
|
||||
return movies, nil
|
||||
}
|
||||
|
||||
// AddUnmonitored adds a title without starting a search or monitoring future releases.
|
||||
func (c *Client) AddUnmonitored(ctx context.Context, movie Movie) (Movie, error) {
|
||||
// AddRequested adds a title, monitors it and asks Radarr to search for it immediately.
|
||||
// A request that merely creates an unmonitored catalogue row never reaches a downloader,
|
||||
// which is indistinguishable from a broken button to the viewer who made it.
|
||||
func (c *Client) AddRequested(ctx context.Context, movie Movie) (Movie, error) {
|
||||
var roots []RootFolder
|
||||
if err := c.get(ctx, "/api/v3/rootfolder", &roots); err != nil {
|
||||
return Movie{}, err
|
||||
@@ -132,11 +134,11 @@ func (c *Client) AddUnmonitored(ctx context.Context, movie Movie) (Movie, error)
|
||||
movie.ID = 0
|
||||
movie.RootFolderPath = roots[0].Path
|
||||
movie.QualityProfileID = profiles[0].ID
|
||||
movie.Monitored = false
|
||||
movie.Monitored = true
|
||||
body := struct {
|
||||
Movie
|
||||
AddOptions map[string]bool `json:"addOptions"`
|
||||
}{Movie: movie, AddOptions: map[string]bool{"searchForMovie": false}}
|
||||
}{Movie: movie, AddOptions: map[string]bool{"searchForMovie": true}}
|
||||
var added Movie
|
||||
if err := c.post(ctx, "/api/v3/movie", body, &added); err != nil {
|
||||
return Movie{}, err
|
||||
|
||||
@@ -48,7 +48,7 @@ func TestCalendarUsesV3APIAndKeepsKeyInHeader(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestAddUnmonitoredUsesDefaultsWithoutStartingSearch(t *testing.T) {
|
||||
func TestAddRequestedUsesDefaultsAndStartsSearch(t *testing.T) {
|
||||
upstream := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
switch r.URL.Path {
|
||||
case "/api/v3/rootfolder":
|
||||
@@ -60,13 +60,13 @@ func TestAddUnmonitoredUsesDefaultsWithoutStartingSearch(t *testing.T) {
|
||||
if err := json.NewDecoder(r.Body).Decode(&body); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if body["monitored"] != false || body["rootFolderPath"] != "/movies" ||
|
||||
if body["monitored"] != true || body["rootFolderPath"] != "/movies" ||
|
||||
body["qualityProfileId"] != float64(4) {
|
||||
t.Errorf("unexpected add body: %#v", body)
|
||||
}
|
||||
options := body["addOptions"].(map[string]any)
|
||||
if options["searchForMovie"] != false {
|
||||
t.Errorf("movie search was enabled: %#v", body)
|
||||
if options["searchForMovie"] != true {
|
||||
t.Errorf("movie search was not enabled: %#v", body)
|
||||
}
|
||||
_, _ = w.Write([]byte(`{"id":9,"tmdbId":22,"title":"Arrival"}`))
|
||||
default:
|
||||
@@ -75,8 +75,8 @@ func TestAddUnmonitoredUsesDefaultsWithoutStartingSearch(t *testing.T) {
|
||||
}))
|
||||
defer upstream.Close()
|
||||
|
||||
added, err := New(upstream.URL, "secret", time.Second).AddUnmonitored(
|
||||
context.Background(), Movie{TMDBID: 22, Title: "Arrival", Monitored: true},
|
||||
added, err := New(upstream.URL, "secret", time.Second).AddRequested(
|
||||
context.Background(), Movie{TMDBID: 22, Title: "Arrival"},
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
||||
Reference in New Issue
Block a user