From bdf280e72b13418613ef78e0a92064591f08aa50 Mon Sep 17 00:00:00 2001 From: Matthias Radestock Date: Thu, 21 Dec 2017 19:31:10 +0000 Subject: [PATCH] add a basic test for rendering nodes with little/no metadata --- render/detailed/summary_test.go | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/render/detailed/summary_test.go b/render/detailed/summary_test.go index b110ea2f86..ad559ff20d 100644 --- a/render/detailed/summary_test.go +++ b/render/detailed/summary_test.go @@ -198,6 +198,38 @@ func TestMakeNodeSummary(t *testing.T) { } } +func TestMakeNodeSummaryNoMetadata(t *testing.T) { + processNameTopology := render.MakeGroupNodeTopology(report.Process, process.Name) + for topology, id := range map[string]string{ + render.Pseudo: render.MakePseudoNodeID("id"), + report.Process: report.MakeProcessNodeID("ip-123-45-6-100", "1234"), + report.Container: report.MakeContainerNodeID("0001accbecc2c95e650fe641926fb923b7cc307a71101a1200af3759227b6d7d"), + report.ContainerImage: report.MakeContainerImageNodeID("0001accbecc2c95e650fe641926fb923b7cc307a71101a1200af3759227b6d7d"), + report.Pod: report.MakePodNodeID("005e2999-d429-11e7-8535-0a41257e78e8"), + report.Service: report.MakeServiceNodeID("005e2999-d429-11e7-8535-0a41257e78e8"), + report.Deployment: report.MakeDeploymentNodeID("005e2999-d429-11e7-8535-0a41257e78e8"), + report.DaemonSet: report.MakeDaemonSetNodeID("005e2999-d429-11e7-8535-0a41257e78e8"), + report.StatefulSet: report.MakeStatefulSetNodeID("005e2999-d429-11e7-8535-0a41257e78e8"), + report.CronJob: report.MakeCronJobNodeID("005e2999-d429-11e7-8535-0a41257e78e8"), + report.ECSTask: report.MakeECSTaskNodeID("arn:aws:ecs:us-east-1:012345678910:task/1dc5c17a-422b-4dc4-b493-371970c6c4d6"), + report.ECSService: report.MakeECSServiceNodeID("cluster", "service"), + report.SwarmService: report.MakeSwarmServiceNodeID("0001accbecc2c95e650fe641926fb923b7cc307a71101a1200af3759227b6d7d"), + report.Host: report.MakeHostNodeID("ip-123-45-6-100"), + report.Overlay: report.MakeOverlayNodeID("", "3e:ca:14:ca:12:5c"), + processNameTopology: "/home/weave/scope", + } { + summary, b := detailed.MakeNodeSummary(report.RenderContext{}, report.MakeNode(id).WithTopology(topology)) + switch true { + case !b: + t.Errorf("Node Summary missing for topology %s, id %s", topology, id) + case summary.Label == "": + t.Errorf("Node Summary Label missing for topology %s, id %s", topology, id) + case summary.Label == id && topology != processNameTopology: + t.Errorf("Node Summary Label same as id (that's cheating!) for topology %s, id %s", topology, id) + } + } +} + func TestNodeMetadata(t *testing.T) { inputs := []struct { name string