MCPcopy Create free account
hub / github.com/github/gh-aw / TestRenderSlice_StructsAsTable

Function TestRenderSlice_StructsAsTable

pkg/console/render_slice_test.go:139–169  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

137}
138
139func TestRenderSlice_StructsAsTable(t *testing.T) {
140 var output strings.Builder
141 data := []SliceTestStruct{
142 {ID: 1, Name: "first"},
143 {ID: 2, Name: "second"},
144 }
145 val := reflect.ValueOf(data)
146
147 renderSlice(val, "Test Table", &output, 0)
148
149 result := output.String()
150
151 // Should have title
152 if !strings.Contains(result, "# Test Table") {
153 t.Errorf("Output should contain title, got: %q", result)
154 }
155
156 // Should render as table (check for table headers from console tags)
157 if !strings.Contains(result, "ID") {
158 t.Error("Output should contain ID column header")
159 }
160 if !strings.Contains(result, "Name") {
161 t.Error("Output should contain Name column header")
162 }
163 if !strings.Contains(result, "first") {
164 t.Error("Output should contain data from first row")
165 }
166 if !strings.Contains(result, "second") {
167 t.Error("Output should contain data from second row")
168 }
169}
170
171func TestRenderSlice_PointerToStructsAsTable(t *testing.T) {
172 var output strings.Builder

Callers

nothing calls this directly

Calls 4

renderSliceFunction · 0.85
StringMethod · 0.45
ErrorfMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected