command: placeholder for <none> in kv output

This commit is contained in:
Ryan Uber 2015-09-27 14:04:53 -07:00
parent 5ce6f4bb64
commit 079b3c753a
2 changed files with 4 additions and 2 deletions

View File

@ -8,6 +8,7 @@ import (
// aligned k = v pairs using the columnize library.
func formatKV(in []string) string {
columnConf := columnize.DefaultConfig()
columnConf.Empty = "<none>"
columnConf.Glue = " = "
return columnize.Format(in, columnConf)
}

View File

@ -5,11 +5,12 @@ import (
)
func TestHelpers_FormatKV(t *testing.T) {
in := []string{"alpha|beta", "charlie|delta"}
in := []string{"alpha|beta", "charlie|delta", "echo|"}
out := formatKV(in)
expect := "alpha = beta\n"
expect += "charlie = delta"
expect += "charlie = delta\n"
expect += "echo = <none>"
if out != expect {
t.Fatalf("expect: %s, got: %s", expect, out)