File tree Expand file tree Collapse file tree 2 files changed +32
-1
lines changed
Expand file tree Collapse file tree 2 files changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -196,7 +196,7 @@ func listTemplates(ctx context.Context, cmd *cli.Command) error {
196196 for _ , t := range templates {
197197 table .Row (
198198 t .Name ,
199- strings .Join (wrapToLines (t .Desc , 40 ), "\n " ),
199+ strings .Join (wrapToLines (t .Desc , maxDescLength ), "\n " ),
200200 strings .Join (t .Tags , ", " ),
201201 )
202202 }
Original file line number Diff line number Diff line change @@ -56,3 +56,34 @@ func TestMapStrings(t *testing.T) {
5656 t .Error ("mapStrings should apply the function to all elements" )
5757 }
5858}
59+
60+ func TestEllipziseTo (t * testing.T ) {
61+ str := "This is some long string that should be ellipsized"
62+ ellipsized := ellipsizeTo (str , 12 )
63+ if len (ellipsized ) != 12 {
64+ t .Error ("ellipsizeTo should return a string of the specified length" )
65+ }
66+ if ellipsized != "This is s..." {
67+ t .Error ("ellipsizeTo should ellipsize the string" )
68+ }
69+ }
70+
71+ func TestWrapToLines (t * testing.T ) {
72+ str := "This is a long string that should be wrapped to multiple lines"
73+ wrapped := wrapToLines (str , 10 )
74+ if len (wrapped ) != 8 {
75+ t .Error ("wrapToLines should return a slice of lines" )
76+ }
77+ if ! slices .Equal ([]string {
78+ "This is a" ,
79+ "long" ,
80+ "string" ,
81+ "that" ,
82+ "should be" ,
83+ "wrapped to" ,
84+ "multiple" ,
85+ "lines" ,
86+ }, wrapped ) {
87+ t .Error ("wrapToLines should wrap the string to the specified width" )
88+ }
89+ }
You can’t perform that action at this time.
0 commit comments