mirror of
https://github.com/idanoo/autobrr
synced 2025-07-23 00:39:13 +00:00
feat(clients): add support for qBittorrent 4.4.0+ (#558)
* refactor: move client to go-qbittorrent * refactor: move client to go-qbittorrent * feat(downloadclient): cache qbittorrent client * feat(downloadclient): update qbit * feat(downloadclient): client test and remove pkg qbit * feat(downloadclient): update pkg qbit * fix(release): method * feat(release): make GetCachedClient concurrent safe * feat(release): add additional tests for buildLegacyHost * feat(release): remove branching * chore: update pkg autobrr/go-qbittorrent to v.1.2.0
This commit is contained in:
parent
6ad4abe296
commit
29da2416ec
17 changed files with 379 additions and 1764 deletions
155
internal/domain/client_test.go
Normal file
155
internal/domain/client_test.go
Normal file
|
@ -0,0 +1,155 @@
|
|||
package domain
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestDownloadClient_qbitBuildLegacyHost(t *testing.T) {
|
||||
type fields struct {
|
||||
ID int
|
||||
Name string
|
||||
Type DownloadClientType
|
||||
Enabled bool
|
||||
Host string
|
||||
Port int
|
||||
TLS bool
|
||||
TLSSkipVerify bool
|
||||
Username string
|
||||
Password string
|
||||
Settings DownloadClientSettings
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
fields fields
|
||||
want string
|
||||
}{
|
||||
{
|
||||
name: "build_url_1",
|
||||
fields: fields{
|
||||
Host: "https://qbit.domain.ltd",
|
||||
Port: 0,
|
||||
Username: "",
|
||||
Password: "",
|
||||
TLS: true,
|
||||
TLSSkipVerify: false,
|
||||
},
|
||||
want: "https://qbit.domain.ltd",
|
||||
},
|
||||
{
|
||||
name: "build_url_2",
|
||||
fields: fields{
|
||||
Host: "http://qbit.domain.ltd",
|
||||
Port: 0,
|
||||
Username: "",
|
||||
Password: "",
|
||||
TLS: false,
|
||||
TLSSkipVerify: false,
|
||||
},
|
||||
want: "http://qbit.domain.ltd",
|
||||
},
|
||||
{
|
||||
name: "build_url_3",
|
||||
fields: fields{
|
||||
Host: "https://qbit.domain.ltd:8080",
|
||||
Port: 0,
|
||||
Username: "",
|
||||
Password: "",
|
||||
TLS: true,
|
||||
TLSSkipVerify: false,
|
||||
},
|
||||
want: "https://qbit.domain.ltd:8080",
|
||||
},
|
||||
{
|
||||
name: "build_url_4",
|
||||
fields: fields{
|
||||
Host: "qbit.domain.ltd:8080",
|
||||
Port: 0,
|
||||
Username: "",
|
||||
Password: "",
|
||||
TLS: false,
|
||||
TLSSkipVerify: false,
|
||||
},
|
||||
want: "http://qbit.domain.ltd:8080",
|
||||
},
|
||||
{
|
||||
name: "build_url_5",
|
||||
fields: fields{
|
||||
Host: "qbit.domain.ltd",
|
||||
Port: 8080,
|
||||
Username: "",
|
||||
Password: "",
|
||||
TLS: false,
|
||||
TLSSkipVerify: false,
|
||||
},
|
||||
want: "http://qbit.domain.ltd:8080",
|
||||
},
|
||||
{
|
||||
name: "build_url_6",
|
||||
fields: fields{
|
||||
Host: "qbit.domain.ltd",
|
||||
Port: 443,
|
||||
Username: "",
|
||||
Password: "",
|
||||
TLS: true,
|
||||
TLSSkipVerify: false,
|
||||
},
|
||||
want: "https://qbit.domain.ltd",
|
||||
},
|
||||
{
|
||||
name: "build_url_7",
|
||||
fields: fields{
|
||||
Host: "qbit.domain.ltd",
|
||||
Port: 10200,
|
||||
Username: "",
|
||||
Password: "",
|
||||
TLS: false,
|
||||
TLSSkipVerify: false,
|
||||
},
|
||||
want: "http://qbit.domain.ltd:10200",
|
||||
},
|
||||
{
|
||||
name: "build_url_8",
|
||||
fields: fields{
|
||||
Host: "https://domain.ltd/qbittorrent",
|
||||
Port: 0,
|
||||
Username: "",
|
||||
Password: "",
|
||||
TLS: true,
|
||||
TLSSkipVerify: false,
|
||||
},
|
||||
want: "https://domain.ltd/qbittorrent",
|
||||
},
|
||||
{
|
||||
name: "build_url_9",
|
||||
fields: fields{
|
||||
Host: "127.0.0.1",
|
||||
Port: 8080,
|
||||
Username: "",
|
||||
Password: "",
|
||||
TLS: false,
|
||||
TLSSkipVerify: false,
|
||||
},
|
||||
want: "http://127.0.0.1:8080",
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
c := DownloadClient{
|
||||
ID: tt.fields.ID,
|
||||
Name: tt.fields.Name,
|
||||
Type: tt.fields.Type,
|
||||
Enabled: tt.fields.Enabled,
|
||||
Host: tt.fields.Host,
|
||||
Port: tt.fields.Port,
|
||||
TLS: tt.fields.TLS,
|
||||
TLSSkipVerify: tt.fields.TLSSkipVerify,
|
||||
Username: tt.fields.Username,
|
||||
Password: tt.fields.Password,
|
||||
Settings: tt.fields.Settings,
|
||||
}
|
||||
assert.Equalf(t, tt.want, c.qbitBuildLegacyHost(), "qbitBuildLegacyHost()")
|
||||
})
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue