add tests
This commit is contained in:
parent
22b6dbaad3
commit
fed64f3ad7
1
app.go
1
app.go
@ -118,6 +118,7 @@ func NewApp() *App {
|
||||
Action: helpCommand.Action,
|
||||
Compiled: compileTime(),
|
||||
Writer: os.Stdout,
|
||||
ErrWriter: os.Stderr,
|
||||
}
|
||||
}
|
||||
|
||||
|
31
app_test.go
31
app_test.go
@ -2152,3 +2152,34 @@ func newTestApp() *App {
|
||||
a.Writer = ioutil.Discard
|
||||
return a
|
||||
}
|
||||
|
||||
func TestSetupInitializesBothWriters(t *testing.T) {
|
||||
a := &App{}
|
||||
|
||||
a.Setup()
|
||||
|
||||
if a.ErrWriter != os.Stderr {
|
||||
t.Errorf("expected a.ErrWriter to be os.Stderr")
|
||||
}
|
||||
|
||||
if a.Writer != os.Stdout {
|
||||
t.Errorf("expected a.Writer to be os.Stdout")
|
||||
}
|
||||
}
|
||||
|
||||
func TestSetupInitializesOnlyNilWriters(t *testing.T) {
|
||||
wr := &bytes.Buffer{}
|
||||
a := &App{
|
||||
ErrWriter: wr,
|
||||
}
|
||||
|
||||
a.Setup()
|
||||
|
||||
if a.ErrWriter != wr {
|
||||
t.Errorf("expected a.ErrWriter to be a *bytes.Buffer instance")
|
||||
}
|
||||
|
||||
if a.Writer != os.Stdout {
|
||||
t.Errorf("expected a.Writer to be os.Stdout")
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user