mirror of
https://github.com/idanoo/autobrr
synced 2025-07-23 08:49:13 +00:00
fix(indexer): panic on size check via api (#239)
* fix(indexer): panic on size check via api * feat(indexer): add mock api
This commit is contained in:
parent
824aecafdf
commit
9e5b7b0aa5
5 changed files with 91 additions and 58 deletions
46
internal/mock/indexer_api.go
Normal file
46
internal/mock/indexer_api.go
Normal file
|
@ -0,0 +1,46 @@
|
|||
package mock
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/autobrr/autobrr/internal/domain"
|
||||
)
|
||||
|
||||
type IndexerApiClient interface {
|
||||
GetTorrentByID(torrentID string) (*domain.TorrentBasic, error)
|
||||
TestAPI() (bool, error)
|
||||
}
|
||||
|
||||
type IndexerClient struct {
|
||||
URL string
|
||||
APIKey string
|
||||
}
|
||||
|
||||
func NewMockClient(url string, apiKey string) IndexerApiClient {
|
||||
c := &IndexerClient{
|
||||
URL: url,
|
||||
APIKey: apiKey,
|
||||
}
|
||||
|
||||
return c
|
||||
}
|
||||
|
||||
func (c *IndexerClient) GetTorrentByID(torrentID string) (*domain.TorrentBasic, error) {
|
||||
if torrentID == "" {
|
||||
return nil, fmt.Errorf("mock client: must have torrentID")
|
||||
}
|
||||
|
||||
r := &domain.TorrentBasic{
|
||||
Id: torrentID,
|
||||
InfoHash: "",
|
||||
Size: "10GB",
|
||||
}
|
||||
|
||||
return r, nil
|
||||
|
||||
}
|
||||
|
||||
// TestAPI try api access against torrents page
|
||||
func (c *IndexerClient) TestAPI() (bool, error) {
|
||||
return true, nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue