Change process-to-container from Map to Renderer

This allows us to be more efficient when collating the data.
This commit is contained in:
Bryan Boreham
2020-06-07 11:12:02 +00:00
parent 7163f42170
commit 7c54093bf7
2 changed files with 25 additions and 58 deletions

View File

@@ -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)