mirror of
https://github.com/weaveworks/scope.git
synced 2026-07-29 02:01:43 +00:00
Change process-to-container from Map to Renderer
This allows us to be more efficient when collating the data.
This commit is contained in:
@@ -2,7 +2,6 @@ package render_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/weaveworks/common/test"
|
||||
@@ -25,32 +24,6 @@ var (
|
||||
})
|
||||
)
|
||||
|
||||
func TestMapProcess2Container(t *testing.T) {
|
||||
for _, input := range []testcase{
|
||||
{"empty", report.MakeNode("empty"), true},
|
||||
{"basic process", report.MakeNodeWith("basic", map[string]string{report.PID: "201", report.DockerContainerID: "a1b2c3"}), true},
|
||||
{"uncontained", report.MakeNodeWith("uncontained", map[string]string{report.PID: "201", report.HostNodeID: report.MakeHostNodeID("foo")}), true},
|
||||
} {
|
||||
testMap(t, render.MapProcess2Container, input)
|
||||
}
|
||||
}
|
||||
|
||||
type testcase struct {
|
||||
name string
|
||||
n report.Node
|
||||
ok bool
|
||||
}
|
||||
|
||||
func testMap(t *testing.T, f render.MapFunc, input testcase) {
|
||||
if have := f(input.n); input.ok != (have.ID != "") {
|
||||
name := input.name
|
||||
if name == "" {
|
||||
name = fmt.Sprintf("%v", input.n)
|
||||
}
|
||||
t.Errorf("%s: want %v, have %v", name, input.ok, have)
|
||||
}
|
||||
}
|
||||
|
||||
func TestContainerRenderer(t *testing.T) {
|
||||
have := utils.Prune(render.ContainerWithImageNameRenderer.Render(context.Background(), fixture.Report).Nodes)
|
||||
want := utils.Prune(expected.RenderedContainers)
|
||||
|
||||
Reference in New Issue
Block a user