Skip to content

Commit

Permalink
add a basic test for rendering nodes with little/no metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
rade committed Dec 24, 2017
1 parent 098486a commit bdf280e
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions render/detailed/summary_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit bdf280e

Please sign in to comment.