mirror of
https://github.com/idanoo/autobrr
synced 2025-07-22 16:29:12 +00:00
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:
parent
fb9dcc23a0
commit
f3cfeed8cd
19 changed files with 475 additions and 191 deletions
|
@ -1,12 +1,14 @@
|
|||
package btn
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/autobrr/autobrr/internal/domain"
|
||||
"github.com/autobrr/autobrr/pkg/errors"
|
||||
)
|
||||
|
||||
func (c *Client) TestAPI() (bool, error) {
|
||||
res, err := c.rpcClient.Call("userInfo", [2]string{c.APIKey})
|
||||
func (c *Client) TestAPI(ctx context.Context) (bool, error) {
|
||||
res, err := c.rpcClient.CallCtx(ctx, "userInfo", [2]string{c.APIKey})
|
||||
if err != nil {
|
||||
return false, errors.Wrap(err, "test api userInfo failed")
|
||||
}
|
||||
|
@ -24,12 +26,12 @@ func (c *Client) TestAPI() (bool, error) {
|
|||
return false, nil
|
||||
}
|
||||
|
||||
func (c *Client) GetTorrentByID(torrentID string) (*domain.TorrentBasic, error) {
|
||||
func (c *Client) GetTorrentByID(ctx context.Context, torrentID string) (*domain.TorrentBasic, error) {
|
||||
if torrentID == "" {
|
||||
return nil, errors.New("btn client: must have torrentID")
|
||||
}
|
||||
|
||||
res, err := c.rpcClient.Call("getTorrentById", [2]string{c.APIKey, torrentID})
|
||||
res, err := c.rpcClient.CallCtx(ctx, "getTorrentById", [2]string{c.APIKey, torrentID})
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "call getTorrentById failed")
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue