mirror of
https://github.com/AlistGo/alist.git
synced 2025-04-21 20:18:47 +08:00
test(aria2): init aria2 client
This commit is contained in:
parent
3fe0a7bf6b
commit
2612cd7f1c
@ -5,6 +5,7 @@ import (
|
||||
"github.com/alist-org/alist/v3/pkg/aria2/rpc"
|
||||
"github.com/alist-org/alist/v3/pkg/task"
|
||||
"github.com/pkg/errors"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"time"
|
||||
)
|
||||
|
||||
@ -18,6 +19,11 @@ func InitAria2Client(uri string, secret string, timeout int) error {
|
||||
return errors.Wrap(err, "failed to init aria2 client")
|
||||
}
|
||||
client = c
|
||||
version, err := client.GetVersion()
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed get aria2 version")
|
||||
}
|
||||
log.Infof("using aria2 version: %s", version.Version)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
10
internal/aria2/aria2_test.go
Normal file
10
internal/aria2/aria2_test.go
Normal file
@ -0,0 +1,10 @@
|
||||
package aria2
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestConnect(t *testing.T) {
|
||||
err := InitAria2Client("http://localhost:16800/jsonrpc", "secret", 3)
|
||||
if err != nil {
|
||||
t.Errorf("failed to init aria2: %+v", err)
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user