MCPcopy Create free account
hub / github.com/aws-cloudformation/rain / TestTable_WithHeaderFormatter

Function TestTable_WithHeaderFormatter

internal/table/table_test.go:45–66  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

43}
44
45func TestTable_WithHeaderFormatter(t *testing.T) {
46 t.Parallel()
47
48 uppercase := func(f string, v ...interface{}) string {
49 return strings.ToUpper(fmt.Sprintf(f, v...))
50 }
51 buf := bytes.Buffer{}
52
53 tbl := New("foo", "bar").WithWriter(&buf).WithHeaderFormatter(uppercase)
54 tbl.Print()
55 out := buf.String()
56
57 assert.Contains(t, out, "FOO")
58 assert.Contains(t, out, "BAR")
59
60 buf.Reset()
61 tbl.WithHeaderFormatter(nil).Print()
62 out = buf.String()
63
64 assert.Contains(t, out, "foo")
65 assert.Contains(t, out, "bar")
66}
67
68func TestTable_WithFirstColumnFormatter(t *testing.T) {
69 t.Parallel()

Callers

nothing calls this directly

Calls 5

NewFunction · 0.70
WithHeaderFormatterMethod · 0.65
WithWriterMethod · 0.65
PrintMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected