feat(indexers): test API from settings (#829)

* refactor(indexers): test api clients

* feat(indexers): test api connection

* fix(indexers): api client tests

* refactor: indexer api clients

* feat: add Toasts for indexer api tests

* fix: failing red tests
This commit is contained in:
ze0s 2023-04-15 23:34:27 +02:00 committed by GitHub
parent fb9dcc23a0
commit f3cfeed8cd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 475 additions and 191 deletions

View file

@ -1,6 +1,7 @@
package red
import (
"context"
"net/http"
"net/http/httptest"
"os"
@ -79,7 +80,7 @@ func TestREDClient_GetTorrentByID(t *testing.T) {
},
args: args{torrentID: "100002"},
want: nil,
wantErr: "could not get torrent by id: 100002: bad id parameter",
wantErr: "could not get torrent by id: 100002: status code: 400 status: failure error: bad id parameter",
},
{
name: "get_by_id_3",
@ -89,14 +90,15 @@ func TestREDClient_GetTorrentByID(t *testing.T) {
},
args: args{torrentID: "100002"},
want: nil,
wantErr: "could not get torrent by id: 100002: unauthorized: bad credentials",
wantErr: "could not get torrent by id: 100002: RED client missing API key!",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
c := NewClient(tt.fields.Url, tt.fields.APIKey)
c := NewClient(tt.fields.APIKey)
c.UseURL(tt.fields.Url)
got, err := c.GetTorrentByID(tt.args.torrentID)
got, err := c.GetTorrentByID(context.Background(), tt.args.torrentID)
if tt.wantErr != "" && assert.Error(t, err) {
assert.EqualErrorf(t, err, tt.wantErr, "Error should be: %v, got: %v", tt.wantErr, err)
}