@@ -45,3 +45,77 @@ func TestPrintFilesTable_smoke(t *testing.T) {
4545 // Just ensure no panic.
4646 console .PrintFilesTable ([][]string {{"file.go" , "main source" }}, "Files" )
4747}
48+
49+ func TestPrintFilesTable_noTitle (t * testing.T ) {
50+ // Empty title should not panic.
51+ console .PrintFilesTable ([][]string {{"a.go" , "pkg a" }, {"b.go" , "pkg b" }}, "" )
52+ }
53+
54+ func TestPrintFilesTable_emptyRows (t * testing.T ) {
55+ console .PrintFilesTable ([][]string {}, "No Files" )
56+ }
57+
58+ func TestEcho_nilWriter (t * testing.T ) {
59+ t .Setenv ("NO_COLOR" , "1" )
60+ // nil writer falls back to os.Stdout -- just ensure no panic.
61+ defer func () {
62+ if r := recover (); r != nil {
63+ t .Errorf ("unexpected panic: %v" , r )
64+ }
65+ }()
66+ console .Echo (nil , "msg" , "" , "" , false )
67+ }
68+
69+ func TestEcho_unknownSymbol (t * testing.T ) {
70+ t .Setenv ("NO_COLOR" , "1" )
71+ var buf bytes.Buffer
72+ // Unknown symbol keys should not appear as prefix.
73+ console .Echo (& buf , "msg" , "" , "notasymbol" , false )
74+ if ! strings .Contains (buf .String (), "msg" ) {
75+ t .Errorf ("expected 'msg' in output, got %q" , buf .String ())
76+ }
77+ }
78+
79+ func TestEcho_boldFlag (t * testing.T ) {
80+ t .Setenv ("NO_COLOR" , "1" )
81+ var buf bytes.Buffer
82+ console .Echo (& buf , "bold text" , "green" , "" , true )
83+ if ! strings .Contains (buf .String (), "bold text" ) {
84+ t .Errorf ("expected 'bold text' in output, got %q" , buf .String ())
85+ }
86+ }
87+
88+ func TestStatusSymbols_extraKeys (t * testing.T ) {
89+ extras := []string {"running" , "gear" , "cross" , "list" , "preview" , "download" , "update" , "remove" }
90+ for _ , k := range extras {
91+ if v := console .StatusSymbols [k ]; v == "" {
92+ t .Errorf ("StatusSymbols[%q] is empty" , k )
93+ }
94+ }
95+ }
96+
97+ func TestDownloadSpinner_smoke (t * testing.T ) {
98+ called := false
99+ console .DownloadSpinner ("test-repo" , func () { called = true })
100+ if ! called {
101+ t .Error ("expected callback to be called" )
102+ }
103+ }
104+
105+ func TestPanel_noTitle (t * testing.T ) {
106+ defer func () {
107+ if r := recover (); r != nil {
108+ t .Errorf ("Panel panicked: %v" , r )
109+ }
110+ }()
111+ console .Panel ("content here" , "" , "default" )
112+ }
113+
114+ func TestPanel_withTitle (t * testing.T ) {
115+ defer func () {
116+ if r := recover (); r != nil {
117+ t .Errorf ("Panel panicked: %v" , r )
118+ }
119+ }()
120+ console .Panel ("content here" , "Section Title" , "default" )
121+ }
0 commit comments