Replace olekukonko/tablewriter with cheynewallace/tabby

- Closes #1497
- Closes #1498

This library is simpler and doesn't produce extraneous whitespace around
the output.

A local helper function restores "--" for empty output.

Signed-off-by: Jonathon Anderson <janderson@ciq.com>
This commit is contained in:
Jonathon Anderson
2024-11-07 16:17:40 -07:00
parent 3cbb295e7b
commit a8554b0af5
11 changed files with 194 additions and 168 deletions

View File

@@ -24,8 +24,11 @@ func Test_List(t *testing.T) {
{
name: "container list test",
args: []string{"-l"},
stdout: ` CONTAINER NAME NODES KERNEL VERSION CREATION TIME MODIFICATION TIME SIZE
test 1 kernel`,
stdout: `
CONTAINER NAME NODES KERNEL VERSION CREATION TIME MODIFICATION TIME SIZE
-------------- ----- -------------- ------------- ----------------- ----
test 1 kernel 01 Jan 70 00:00 UTC 01 Jan 70 00:00 UTC 0 B
`,
inDb: `WW_INTERNAL: 43
nodeprofiles:
default: {}
@@ -61,14 +64,12 @@ nodes:
buf := new(bytes.Buffer)
baseCmd := GetCommand()
baseCmd.SetArgs(tt.args)
baseCmd.SetOut(nil)
baseCmd.SetErr(nil)
baseCmd.SetOut(buf)
baseCmd.SetErr(buf)
wwlog.SetLogWriter(buf)
err := baseCmd.Execute()
assert.NoError(t, err)
assert.Contains(t,
strings.Join(strings.Fields(buf.String()), ""),
strings.Join(strings.Fields(tt.stdout), ""))
assert.Equal(t, strings.TrimSpace(tt.stdout), strings.TrimSpace(buf.String()))
})
}
}