File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ package cli
3
3
import (
4
4
"bytes"
5
5
"context"
6
+ "errors"
6
7
"flag"
7
8
"fmt"
8
9
"io"
@@ -1779,3 +1780,20 @@ func TestNIndent(t *testing.T) {
1779
1780
assert .Equal (t , "\n foo" , nindent (2 , "foo" ))
1780
1781
assert .Equal (t , "\n foo\n " , nindent (2 , "foo\n " ))
1781
1782
}
1783
+
1784
+ func TestTemplateError (t * testing.T ) {
1785
+ oldew := ErrWriter
1786
+ defer func () { ErrWriter = oldew }()
1787
+
1788
+ var buf bytes.Buffer
1789
+ ErrWriter = & buf
1790
+ err := errors .New ("some error" )
1791
+
1792
+ handleTemplateError (err )
1793
+ assert .Equal (t , []byte (nil ), buf .Bytes ())
1794
+
1795
+ os .Setenv ("CLI_TEMPLATE_ERROR_DEBUG" , "true" )
1796
+ handleTemplateError (err )
1797
+ assert .Contains (t , buf .String (), "CLI TEMPLATE ERROR" )
1798
+ assert .Contains (t , buf .String (), err .Error ())
1799
+ }
You can’t perform that action at this time.
0 commit comments