mirror of
https://github.com/weaveworks/scope.git
synced 2026-03-04 02:30:45 +00:00
- 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)
31 lines
713 B
Go
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)
|
|
}
|
|
}
|
|
}
|