mirror of
https://github.com/weaveworks/scope.git
synced 2026-03-04 18:51:17 +00:00
We want to be able to import test from packages like probe/endpoint, in order to use utility functions like poll. But that causes an import cycle with the current layout. We got around this using dot-imports so far, but it's ugly and unnecessary: fixture can be its own package.
34 lines
771 B
Go
34 lines
771 B
Go
package main
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
"net/http/httptest"
|
|
"testing"
|
|
|
|
"github.com/weaveworks/scope/test/fixture"
|
|
)
|
|
|
|
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, fmt.Sprintf("/api/origin/host/%s", fixture.ServerHostNodeID))
|
|
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 := "0.01 0.01 0.01", o.Load; want != have {
|
|
t.Errorf("Origin error. Want %v, have %v", want, have)
|
|
}
|
|
}
|
|
}
|