mirror of
https://github.com/weaveworks/scope.git
synced 2026-03-03 18:20:27 +00:00
34 lines
657 B
Go
34 lines
657 B
Go
package app_test
|
|
|
|
import (
|
|
"encoding/json"
|
|
"net/http/httptest"
|
|
"testing"
|
|
|
|
"github.com/gorilla/mux"
|
|
|
|
"github.com/weaveworks/scope/app"
|
|
"github.com/weaveworks/scope/report"
|
|
)
|
|
|
|
func topologyServer() *httptest.Server {
|
|
router := mux.NewRouter()
|
|
app.RegisterTopologyRoutes(StaticReport{}, router)
|
|
return httptest.NewServer(router)
|
|
}
|
|
|
|
func TestAPIReport(t *testing.T) {
|
|
ts := topologyServer()
|
|
defer ts.Close()
|
|
|
|
is404(t, ts, "/api/report/foobar")
|
|
|
|
var body = getRawJSON(t, ts, "/api/report")
|
|
// fmt.Printf("Body: %v\n", string(body))
|
|
var r report.Report
|
|
err := json.Unmarshal(body, &r)
|
|
if err != nil {
|
|
t.Fatalf("JSON parse error: %s", err)
|
|
}
|
|
}
|