mirror of
https://github.com/halejohn/Cloudreve.git
synced 2026-01-26 09:34:57 +08:00
Fix: get site summary in dashboard
This commit is contained in:
@@ -1,23 +0,0 @@
|
||||
package rpc
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestWebsocketCaller(t *testing.T) {
|
||||
time.Sleep(time.Second)
|
||||
c, err := newWebsocketCaller(context.Background(), "ws://localhost:6800/jsonrpc", time.Second, &DummyNotifier{})
|
||||
if err != nil {
|
||||
t.Fatal(err.Error())
|
||||
}
|
||||
defer c.Close()
|
||||
|
||||
var info VersionInfo
|
||||
if err := c.Call(aria2GetVersion, []interface{}{}, &info); err != nil {
|
||||
t.Error(err.Error())
|
||||
} else {
|
||||
println(info.Version)
|
||||
}
|
||||
}
|
||||
@@ -1,125 +0,0 @@
|
||||
package rpc
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestHTTPAll(t *testing.T) {
|
||||
const targetURL = "https://nodejs.org/dist/index.json"
|
||||
rpc, err := New(context.Background(), "http://localhost:6800/jsonrpc", "", time.Second, &DummyNotifier{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer rpc.Close()
|
||||
g, err := rpc.AddURI(targetURL)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
println(g)
|
||||
if _, err = rpc.TellActive(); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if _, err = rpc.PauseAll(); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if _, err = rpc.TellStatus(g); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if _, err = rpc.GetURIs(g); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if _, err = rpc.GetFiles(g); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if _, err = rpc.GetPeers(g); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if _, err = rpc.TellActive(); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if _, err = rpc.TellWaiting(0, 1); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if _, err = rpc.TellStopped(0, 1); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if _, err = rpc.GetOption(g); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if _, err = rpc.GetGlobalOption(); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if _, err = rpc.GetGlobalStat(); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if _, err = rpc.GetSessionInfo(); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if _, err = rpc.Remove(g); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if _, err = rpc.TellActive(); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestWebsocketAll(t *testing.T) {
|
||||
const targetURL = "https://nodejs.org/dist/index.json"
|
||||
rpc, err := New(context.Background(), "ws://localhost:6800/jsonrpc", "", time.Second, &DummyNotifier{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer rpc.Close()
|
||||
g, err := rpc.AddURI(targetURL)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
println(g)
|
||||
if _, err = rpc.TellActive(); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if _, err = rpc.PauseAll(); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if _, err = rpc.TellStatus(g); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if _, err = rpc.GetURIs(g); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if _, err = rpc.GetFiles(g); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if _, err = rpc.GetPeers(g); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if _, err = rpc.TellActive(); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if _, err = rpc.TellWaiting(0, 1); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if _, err = rpc.TellStopped(0, 1); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if _, err = rpc.GetOption(g); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if _, err = rpc.GetGlobalOption(); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if _, err = rpc.GetGlobalStat(); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if _, err = rpc.GetSessionInfo(); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if _, err = rpc.Remove(g); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if _, err = rpc.TellActive(); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user