Fix: get site summary in dashboard

This commit is contained in:
HFO4
2020-02-22 16:22:04 +08:00
parent 22cec36751
commit 49f784104e
9 changed files with 116 additions and 150 deletions

View File

@@ -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)
}
}

View File

@@ -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)
}
}