add flag --no-headers to kubectl top ...

This commit is contained in:
WanLinghao
2018-08-27 19:27:48 +08:00
parent 4733b85714
commit c9b6c92f10
5 changed files with 36 additions and 14 deletions

View File

@@ -81,6 +81,7 @@ func TestTopNodeAllMetrics(t *testing.T) {
streams, _, buf, _ := genericclioptions.NewTestIOStreams()
cmd := NewCmdTopNode(tf, nil, streams)
cmd.Flags().Set("no-headers", "true")
cmd.Run(cmd, []string{})
// Check the presence of node names in the output.
@@ -90,6 +91,9 @@ func TestTopNodeAllMetrics(t *testing.T) {
t.Errorf("missing metrics for %s: \n%s", m.Name, result)
}
}
if strings.Contains(result, "MEMORY") {
t.Errorf("should not print headers with --no-headers option set:\n%s\n", result)
}
}
func TestTopNodeAllMetricsCustomDefaults(t *testing.T) {