@@ -347,6 +347,75 @@ func TestTable_Render_AutoMerge_RowsOnly(t *testing.T) {
347
347
└───┴─────────┴────────┴───────────┴───────────┴─────┴─────┘` )
348
348
}
349
349
350
+ func TestTable_Render_AutoMerge_NoHeaderFooter (t * testing.T ) {
351
+ tw := NewWriter ()
352
+ tw .AppendRow (Row {"1.1.1.1" , "Pod 1A" , "NS 1A" , "C 1" , "Y" , "Y" }, RowConfig {AutoMerge : true })
353
+ tw .AppendRow (Row {"1.1.1.1" , "Pod 1A" , "NS 1A" , "C 2" , "Y" , "N" })
354
+ tw .AppendRow (Row {"1.1.1.1" , "Pod 1A" , "NS 1B" , "C 3" , "N" , "N" })
355
+ tw .AppendRow (Row {"1.1.1.1" , "Pod 1B" , "NS 2" , "C 4" , "N" , "N" }, RowConfig {AutoMerge : true })
356
+ tw .AppendRow (Row {"1.1.1.1" , "Pod 1B" , "NS 2" , "C 5" , "Y" , "N" })
357
+ tw .AppendRow (Row {"2.2.2.2" , "Pod 2" , "NS 3" , "C 6" , "Y" , "Y" }, RowConfig {AutoMerge : true })
358
+ tw .AppendRow (Row {"2.2.2.2" , "Pod 2" , "NS 3" , "C 7" , "Y" , "Y" }, RowConfig {AutoMerge : true , AutoMergeAlign : text .AlignRight })
359
+ tw .SetColumnConfigs ([]ColumnConfig {
360
+ {Number : 5 , Align : text .AlignCenter , AlignHeader : text .AlignCenter },
361
+ {Number : 6 , Align : text .AlignCenter , AlignHeader : text .AlignCenter },
362
+ })
363
+ tw .SetStyle (StyleLight )
364
+ tw .Style ().Options .SeparateRows = true
365
+
366
+ compareOutput (t , tw .Render (), `┌─────────┬────────┬───────┬─────┬───────┐
367
+ │ 1.1.1.1 │ Pod 1A │ NS 1A │ C 1 │ Y │
368
+ ├─────────┼────────┼───────┼─────┼───┬───┤
369
+ │ 1.1.1.1 │ Pod 1A │ NS 1A │ C 2 │ Y │ N │
370
+ ├─────────┼────────┼───────┼─────┼───┼───┤
371
+ │ 1.1.1.1 │ Pod 1A │ NS 1B │ C 3 │ N │ N │
372
+ ├─────────┼────────┼───────┼─────┼───┴───┤
373
+ │ 1.1.1.1 │ Pod 1B │ NS 2 │ C 4 │ N │
374
+ ├─────────┼────────┼───────┼─────┼───┬───┤
375
+ │ 1.1.1.1 │ Pod 1B │ NS 2 │ C 5 │ Y │ N │
376
+ ├─────────┼────────┼───────┼─────┼───┴───┤
377
+ │ 2.2.2.2 │ Pod 2 │ NS 3 │ C 6 │ Y │
378
+ ├─────────┼────────┼───────┼─────┼───────┤
379
+ │ 2.2.2.2 │ Pod 2 │ NS 3 │ C 7 │ Y │
380
+ └─────────┴────────┴───────┴─────┴───────┘` )
381
+ }
382
+
383
+ func TestTable_Render_AutoMerge_NoHeaderFooter_AutoIndex (t * testing.T ) {
384
+ tw := NewWriter ()
385
+ tw .AppendRow (Row {"1.1.1.1" , "Pod 1A" , "NS 1A" , "C 1" , "Y" , "Y" }, RowConfig {AutoMerge : true })
386
+ tw .AppendRow (Row {"1.1.1.1" , "Pod 1A" , "NS 1A" , "C 2" , "Y" , "N" })
387
+ tw .AppendRow (Row {"1.1.1.1" , "Pod 1A" , "NS 1B" , "C 3" , "N" , "N" })
388
+ tw .AppendRow (Row {"1.1.1.1" , "Pod 1B" , "NS 2" , "C 4" , "N" , "N" }, RowConfig {AutoMerge : true })
389
+ tw .AppendRow (Row {"1.1.1.1" , "Pod 1B" , "NS 2" , "C 5" , "Y" , "N" })
390
+ tw .AppendRow (Row {"2.2.2.2" , "Pod 2" , "NS 3" , "C 6" , "Y" , "Y" }, RowConfig {AutoMerge : true })
391
+ tw .AppendRow (Row {"2.2.2.2" , "Pod 2" , "NS 3" , "C 7" , "Y" , "Y" }, RowConfig {AutoMerge : true , AutoMergeAlign : text .AlignRight })
392
+ tw .SetAutoIndex (true )
393
+ tw .SetColumnConfigs ([]ColumnConfig {
394
+ {Number : 5 , Align : text .AlignCenter , AlignHeader : text .AlignCenter },
395
+ {Number : 6 , Align : text .AlignCenter , AlignHeader : text .AlignCenter },
396
+ })
397
+ tw .SetStyle (StyleLight )
398
+ tw .Style ().Options .SeparateRows = true
399
+
400
+ compareOutput (t , tw .Render (), `┌───┬─────────┬────────┬───────┬─────┬───┬───┐
401
+ │ │ A │ B │ C │ D │ E │ F │
402
+ ├───┼─────────┼────────┼───────┼─────┼───┴───┤
403
+ │ 1 │ 1.1.1.1 │ Pod 1A │ NS 1A │ C 1 │ Y │
404
+ ├───┼─────────┼────────┼───────┼─────┼───┬───┤
405
+ │ 2 │ 1.1.1.1 │ Pod 1A │ NS 1A │ C 2 │ Y │ N │
406
+ ├───┼─────────┼────────┼───────┼─────┼───┼───┤
407
+ │ 3 │ 1.1.1.1 │ Pod 1A │ NS 1B │ C 3 │ N │ N │
408
+ ├───┼─────────┼────────┼───────┼─────┼───┴───┤
409
+ │ 4 │ 1.1.1.1 │ Pod 1B │ NS 2 │ C 4 │ N │
410
+ ├───┼─────────┼────────┼───────┼─────┼───┬───┤
411
+ │ 5 │ 1.1.1.1 │ Pod 1B │ NS 2 │ C 5 │ Y │ N │
412
+ ├───┼─────────┼────────┼───────┼─────┼───┴───┤
413
+ │ 6 │ 2.2.2.2 │ Pod 2 │ NS 3 │ C 6 │ Y │
414
+ ├───┼─────────┼────────┼───────┼─────┼───────┤
415
+ │ 7 │ 2.2.2.2 │ Pod 2 │ NS 3 │ C 7 │ Y │
416
+ └───┴─────────┴────────┴───────┴─────┴───────┘` )
417
+ }
418
+
350
419
func TestTable_Render_AutoMerge_WithHiddenRows (t * testing.T ) {
351
420
tw := NewWriter ()
352
421
tw .AppendHeader (Row {"Node IP" , "Pods" , "Namespace" , "Container" , "RCE\n EXE" , "RCE\n RUN" })
0 commit comments