fix(actions): cross platform watch dir file handling (#458)

* chore: update deps

* fix(actions): cross-platform file handling

* fix(qbittorrent): unrelated failing test
This commit is contained in:
ze0s 2022-09-10 20:31:46 +02:00 committed by GitHub
parent 8b96f29f37
commit bbb8d2fe6e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 129 additions and 123 deletions

View file

@ -1,9 +1,10 @@
package btn
import (
"io/ioutil"
"io"
"net/http"
"net/http/httptest"
"os"
"strings"
"testing"
@ -34,7 +35,7 @@ func TestAPI(t *testing.T) {
//}
// read json response
jsonPayload, _ := ioutil.ReadFile("testdata/btn_get_user_info.json")
jsonPayload, _ := os.ReadFile("testdata/btn_get_user_info.json")
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
w.Write(jsonPayload)
@ -90,7 +91,7 @@ func TestClient_GetTorrentByID(t *testing.T) {
}
defer r.Body.Close()
data, err := ioutil.ReadAll(r.Body)
data, err := io.ReadAll(r.Body)
if err != nil {
t.Errorf("expected error to be nil got %v", err)
}
@ -105,7 +106,7 @@ func TestClient_GetTorrentByID(t *testing.T) {
}
if !strings.Contains(string(data), key) {
jsonPayload, _ := ioutil.ReadFile("testdata/btn_bad_creds.json")
jsonPayload, _ := os.ReadFile("testdata/btn_bad_creds.json")
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusUnauthorized)
w.Write(jsonPayload)
@ -113,7 +114,7 @@ func TestClient_GetTorrentByID(t *testing.T) {
}
// read json response
jsonPayload, _ := ioutil.ReadFile("testdata/btn_get_torrent_by_id.json")
jsonPayload, _ := os.ReadFile("testdata/btn_get_torrent_by_id.json")
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
w.Write(jsonPayload)

View file

@ -4,7 +4,7 @@ import (
"context"
"encoding/json"
"fmt"
"io/ioutil"
"io"
"net/http"
"net/url"
"strconv"
@ -203,7 +203,7 @@ func (c *client) GetTorrentByID(torrentID string) (*domain.TorrentBasic, error)
defer resp.Body.Close()
body, readErr := ioutil.ReadAll(resp.Body)
body, readErr := io.ReadAll(resp.Body)
if readErr != nil {
return nil, errors.Wrap(readErr, "error reading body")
}

View file

@ -1,9 +1,9 @@
package ggn
import (
"io/ioutil"
"net/http"
"net/http/httptest"
"os"
"strings"
"testing"
@ -29,7 +29,7 @@ func Test_client_GetTorrentByID(t *testing.T) {
}
if !strings.Contains(r.RequestURI, "422368") {
jsonPayload, _ := ioutil.ReadFile("testdata/ggn_get_torrent_by_id_not_found.json")
jsonPayload, _ := os.ReadFile("testdata/ggn_get_torrent_by_id_not_found.json")
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
w.Write(jsonPayload)
@ -37,7 +37,7 @@ func Test_client_GetTorrentByID(t *testing.T) {
}
// read json response
jsonPayload, _ := ioutil.ReadFile("testdata/ggn_get_torrent_by_id.json")
jsonPayload, _ := os.ReadFile("testdata/ggn_get_torrent_by_id.json")
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
w.Write(jsonPayload)

View file

@ -1,9 +1,9 @@
package lidarr
import (
"io/ioutil"
"net/http"
"net/http/httptest"
"os"
"testing"
"github.com/rs/zerolog"
@ -32,7 +32,7 @@ func Test_client_Push(t *testing.T) {
}
// read json response
jsonPayload, _ := ioutil.ReadFile("testdata/release_push_response.json")
jsonPayload, _ := os.ReadFile("testdata/release_push_response.json")
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
w.Write(jsonPayload)
@ -125,7 +125,7 @@ func Test_client_Test(t *testing.T) {
return
}
}
jsonPayload, _ := ioutil.ReadFile("testdata/system_status_response.json")
jsonPayload, _ := os.ReadFile("testdata/system_status_response.json")
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
w.Write(jsonPayload)

View file

@ -4,7 +4,7 @@ import (
"context"
"encoding/json"
"fmt"
"io/ioutil"
"io"
"net/http"
"net/url"
"time"
@ -142,7 +142,7 @@ func (c *Client) GetTorrentByID(torrentID string) (*domain.TorrentBasic, error)
defer resp.Body.Close()
body, readErr := ioutil.ReadAll(resp.Body)
body, readErr := io.ReadAll(resp.Body)
if readErr != nil {
return nil, errors.Wrap(readErr, "could not read body")
}

View file

@ -1,9 +1,9 @@
package ptp
import (
"io/ioutil"
"net/http"
"net/http/httptest"
"os"
"testing"
"github.com/autobrr/autobrr/internal/domain"
@ -36,7 +36,7 @@ func TestPTPClient_GetTorrentByID(t *testing.T) {
}
// read json response
jsonPayload, _ := ioutil.ReadFile("testdata/ptp_get_torrent_by_id.json")
jsonPayload, _ := os.ReadFile("testdata/ptp_get_torrent_by_id.json")
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
w.Write(jsonPayload)

View file

@ -88,6 +88,7 @@ func TestTorrentAddOptions_Prepare(t *testing.T) {
want: map[string]string{
"skip_checking": "true",
"root_folder": "true",
"contentLayout": "Subfolder",
"autoTMM": "false",
"ratioLimit": "2.00",
"savepath": "/home/test/torrents",
@ -116,6 +117,7 @@ func TestTorrentAddOptions_Prepare(t *testing.T) {
want: map[string]string{
"skip_checking": "true",
"root_folder": "false",
"contentLayout": "NoSubfolder",
"autoTMM": "false",
"ratioLimit": "2.00",
"savepath": "/home/test/torrents",

View file

@ -2,7 +2,7 @@ package qbittorrent
import (
"encoding/json"
"io/ioutil"
"io"
"net/http"
"net/http/httputil"
"strconv"
@ -30,7 +30,7 @@ func (c *Client) Login() error {
defer resp.Body.Close()
bodyBytes, err := ioutil.ReadAll(resp.Body)
bodyBytes, err := io.ReadAll(resp.Body)
if err != nil {
return err
}
@ -64,7 +64,7 @@ func (c *Client) GetTorrents() ([]Torrent, error) {
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, errors.Wrap(err, "could not read body")
}
@ -89,7 +89,7 @@ func (c *Client) GetTorrentsFilter(filter TorrentFilter) ([]Torrent, error) {
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, errors.Wrap(err, "could not read body")
}
@ -116,7 +116,7 @@ func (c *Client) GetTorrentsActiveDownloads() ([]Torrent, error) {
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, errors.Wrap(err, "could not read body")
}
@ -146,7 +146,7 @@ func (c *Client) GetTorrentsRaw() (string, error) {
defer resp.Body.Close()
data, err := ioutil.ReadAll(resp.Body)
data, err := io.ReadAll(resp.Body)
if err != nil {
return "", errors.Wrap(err, "could not get read body torrents raw")
}
@ -180,7 +180,7 @@ func (c *Client) GetTorrentTrackers(hash string) ([]TorrentTracker, error) {
return nil, nil
}
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, errors.Wrap(err, "could not read body")
}
@ -258,7 +258,7 @@ func (c *Client) GetTransferInfo() (*TransferInfo, error) {
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, errors.Wrap(err, "could not read body")
}
@ -295,7 +295,7 @@ func (c *Client) SetForceStart(hashes []string, value bool) error {
hv := strings.Join(hashes, "|")
opts := map[string]string{
"hashes": hv,
"value": strconv.FormatBool(value),
"value": strconv.FormatBool(value),
}
resp, err := c.get("torrents/setForceStart", opts)
@ -400,7 +400,7 @@ func (c *Client) EditCategory(category string, path string) error {
return nil
}
func (c *Client) RemoveCategories(categories[] string) error {
func (c *Client) RemoveCategories(categories []string) error {
opts := map[string]string{
"categories": strings.Join(categories, "\n"),
}
@ -420,7 +420,7 @@ func (c *Client) SetCategory(hashes []string, category string) error {
// Add hashes together with | separator
hv := strings.Join(hashes, "|")
opts := map[string]string{
"hashes": hv,
"hashes": hv,
"category": category,
}
@ -447,7 +447,7 @@ func (c *Client) GetFilesInformation(hash string) (*TorrentFiles, error) {
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, errors.Wrap(err, "could not read body")
}
@ -468,7 +468,7 @@ func (c *Client) GetCategories() (map[string]Category, error) {
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, errors.Wrap(err, "could not read body")
}

View file

@ -1,9 +1,10 @@
package radarr
import (
"io/ioutil"
"io"
"net/http"
"net/http/httptest"
"os"
"strings"
"testing"
@ -34,13 +35,13 @@ func Test_client_Push(t *testing.T) {
}
defer r.Body.Close()
data, err := ioutil.ReadAll(r.Body)
data, err := io.ReadAll(r.Body)
if err != nil {
t.Errorf("expected error to be nil got %v", err)
}
if strings.Contains(string(data), "Minx 1 epi 9 2160p") {
jsonPayload, _ := ioutil.ReadFile("testdata/release_push_parse_error.json")
jsonPayload, _ := os.ReadFile("testdata/release_push_parse_error.json")
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusBadRequest)
w.Write(jsonPayload)
@ -48,7 +49,7 @@ func Test_client_Push(t *testing.T) {
}
// read json response
jsonPayload, _ := ioutil.ReadFile("testdata/release_push_response.json")
jsonPayload, _ := os.ReadFile("testdata/release_push_response.json")
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
w.Write(jsonPayload)
@ -164,7 +165,7 @@ func Test_client_Test(t *testing.T) {
return
}
}
jsonPayload, _ := ioutil.ReadFile("testdata/system_status_response.json")
jsonPayload, _ := os.ReadFile("testdata/system_status_response.json")
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
w.Write(jsonPayload)

View file

@ -4,7 +4,7 @@ import (
"context"
"encoding/json"
"fmt"
"io/ioutil"
"io"
"net/http"
"net/url"
"strconv"
@ -174,7 +174,7 @@ func (c *Client) GetTorrentByID(torrentID string) (*domain.TorrentBasic, error)
defer resp.Body.Close()
body, readErr := ioutil.ReadAll(resp.Body)
body, readErr := io.ReadAll(resp.Body)
if readErr != nil {
return nil, errors.Wrap(readErr, "could not read body")
}

View file

@ -1,9 +1,9 @@
package red
import (
"io/ioutil"
"net/http"
"net/http/httptest"
"os"
"strings"
"testing"
@ -28,7 +28,7 @@ func TestREDClient_GetTorrentByID(t *testing.T) {
}
if !strings.Contains(r.RequestURI, "29991962") {
jsonPayload, _ := ioutil.ReadFile("testdata/get_torrent_by_id_not_found.json")
jsonPayload, _ := os.ReadFile("testdata/get_torrent_by_id_not_found.json")
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusBadRequest)
w.Write(jsonPayload)
@ -36,7 +36,7 @@ func TestREDClient_GetTorrentByID(t *testing.T) {
}
// read json response
jsonPayload, _ := ioutil.ReadFile("testdata/get_torrent_by_id.json")
jsonPayload, _ := os.ReadFile("testdata/get_torrent_by_id.json")
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
w.Write(jsonPayload)

View file

@ -5,6 +5,7 @@ import (
"log"
"net/http"
"net/http/httptest"
"os"
"testing"
"github.com/stretchr/testify/assert"
@ -35,7 +36,7 @@ func Test_client_Push(t *testing.T) {
}
// read json response
jsonPayload, _ := ioutil.ReadFile("testdata/release_push_response.json")
jsonPayload, _ := os.ReadFile("testdata/release_push_response.json")
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
w.Write(jsonPayload)
@ -133,7 +134,7 @@ func Test_client_Test(t *testing.T) {
return
}
}
jsonPayload, _ := ioutil.ReadFile("testdata/system_status_response.json")
jsonPayload, _ := os.ReadFile("testdata/system_status_response.json")
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
w.Write(jsonPayload)

View file

@ -2,9 +2,9 @@ package torznab
import (
"encoding/xml"
"io/ioutil"
"net/http"
"net/http/httptest"
"os"
"strings"
"testing"
@ -23,7 +23,7 @@ import (
// return
// }
// }
// payload, err := ioutil.ReadFile("testdata/torznab_response.xml")
// payload, err := os.ReadFile("testdata/torznab_response.xml")
// if err != nil {
// http.Error(w, err.Error(), http.StatusInternalServerError)
// return
@ -85,7 +85,7 @@ func TestClient_GetCaps(t *testing.T) {
return
}
payload, err := ioutil.ReadFile("testdata/caps_response.xml")
payload, err := os.ReadFile("testdata/caps_response.xml")
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return