File tree Expand file tree Collapse file tree 2 files changed +19
-2
lines changed
Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -26,8 +26,12 @@ func NewApp() *App {
2626}
2727
2828// SetLogger sets the logger
29- func (a * App ) SetLogger (logger logger.Logger ) {
30- a .logger = logger
29+ func (a * App ) SetLogger (log logger.Logger ) {
30+ if log == nil {
31+ a .logger = logger .NoLogger ()
32+ return
33+ }
34+ a .logger = log
3135}
3236
3337// SetBackupCmd sets the backup command
Original file line number Diff line number Diff line change @@ -29,3 +29,16 @@ func TestRunCommandReportsError(t *testing.T) {
2929 t .Fatalf ("Expected error, got nil" )
3030 }
3131}
32+
33+ func TestSetLoggerNil (t * testing.T ) {
34+ a := app .NewApp ()
35+ if a == nil {
36+ t .Fatalf ("Expected non-nil app, got nil" )
37+ }
38+ a .SetLogger (nil )
39+ a .SetBackupCmd ([]string {"echo" , "hello" })
40+ err := a .Run ()
41+ if err != nil {
42+ t .Fatalf ("Expected nil error, got %v" , err )
43+ }
44+ }
You can’t perform that action at this time.
0 commit comments