mirror of
https://github.com/idanoo/autobrr
synced 2025-07-23 08:49:13 +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,13 +1,15 @@
|
|||
package mock
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/autobrr/autobrr/internal/domain"
|
||||
"github.com/autobrr/autobrr/pkg/errors"
|
||||
)
|
||||
|
||||
type IndexerApiClient interface {
|
||||
GetTorrentByID(torrentID string) (*domain.TorrentBasic, error)
|
||||
TestAPI() (bool, error)
|
||||
GetTorrentByID(ctx context.Context, torrentID string) (*domain.TorrentBasic, error)
|
||||
TestAPI(ctx context.Context) (bool, error)
|
||||
}
|
||||
|
||||
type IndexerClient struct {
|
||||
|
@ -24,7 +26,7 @@ func NewMockClient(url string, apiKey string) IndexerApiClient {
|
|||
return c
|
||||
}
|
||||
|
||||
func (c *IndexerClient) GetTorrentByID(torrentID string) (*domain.TorrentBasic, error) {
|
||||
func (c *IndexerClient) GetTorrentByID(ctx context.Context, torrentID string) (*domain.TorrentBasic, error) {
|
||||
if torrentID == "" {
|
||||
return nil, errors.New("mock client: must have torrentID")
|
||||
}
|
||||
|
@ -40,6 +42,6 @@ func (c *IndexerClient) GetTorrentByID(torrentID string) (*domain.TorrentBasic,
|
|||
}
|
||||
|
||||
// TestAPI try api access against torrents page
|
||||
func (c *IndexerClient) TestAPI() (bool, error) {
|
||||
func (c *IndexerClient) TestAPI(ctx context.Context) (bool, error) {
|
||||
return true, nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue