Files
weave-scope/app/origin_host_test.go
Peter Bourgon d438261742 HostMetadata becomes Host Topology
- All HostMetadata information becomes NodeMetadata
- Significant change to mechanics, but same net effect
- LocalNets becomes "local_networks", space-separated list of CIDRs
- Load becomes simple single string
- Use MakeHostNodeID for indexing into Host topology
- (That changes the app /origin/{id} handler; will be removed later)
2015-06-09 15:38:08 +02:00

31 lines
713 B
Go

package main
import (
"encoding/json"
"net/http/httptest"
"testing"
)
func TestAPIOriginHost(t *testing.T) {
ts := httptest.NewServer(Router(StaticReport{}))
defer ts.Close()
is404(t, ts, "/api/origin/foobar")
is404(t, ts, "/api/origin/host/foobar")
{
// Origin
body := getRawJSON(t, ts, "/api/origin/host/hostA;<host>") // TODO MakeHostNodeID
var o OriginHost
if err := json.Unmarshal(body, &o); err != nil {
t.Fatalf("JSON parse error: %s", err)
}
if want, have := "Linux", o.OS; want != have {
t.Errorf("Origin error. Want %v, have %v", want, have)
}
if want, have := "3.14 2.71 1.61", o.Load; want != have {
t.Errorf("Origin error. Want %v, have %v", want, have)
}
}
}