clusterviz/main_test.go

43 lines
716 B
Go
Raw Normal View History

2018-06-19 15:40:46 +00:00
package main
2018-06-20 14:45:05 +00:00
import (
"context"
"testing"
)
2018-06-19 15:40:46 +00:00
func TestGraphCreate(t *testing.T) {
cluster := NewMockConsulSource()
rpc := NewMockRPCClient()
f := NewFetcher(cluster, rpc)
2018-06-20 14:45:05 +00:00
ctx := context.Background()
nodes, err := f.Nodes(ctx, "", "eth.beta")
2018-06-19 15:40:46 +00:00
if err != nil {
t.Fatal(err)
}
got := len(nodes)
expected := 15
if got != expected {
t.Fatalf("Expected %d nodes, got %d", expected, got)
}
2018-06-20 14:45:05 +00:00
peers, links, err := f.NodePeers(ctx, nodes)
2018-06-19 15:40:46 +00:00
if err != nil {
t.Fatal(err)
}
got = len(peers)
expected = 49
if got != expected {
t.Fatalf("Expected %d nodes, got %d", expected, got)
}
got = len(links)
expected = 200
if got != expected {
t.Fatalf("Expected %d links, got %d", expected, got)
}
}