Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alessio authored and spf13 committed Jun 7, 2019
1 parent cb27ce1 commit e35034f
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1381,6 +1381,30 @@ func TestSetOutput(t *testing.T) {
}
}

func TestSetOut(t *testing.T) {
c := &Command{}
c.SetOut(nil)
if out := c.OutOrStdout(); out != os.Stdout {
t.Errorf("Expected setting output to nil to revert back to stdout")
}
}

func TestSetErr(t *testing.T) {
c := &Command{}
c.SetErr(nil)
if out := c.ErrOrStderr(); out != os.Stderr {
t.Errorf("Expected setting error to nil to revert back to stderr")
}
}

func TestSetIn(t *testing.T) {
c := &Command{}
c.SetIn(nil)
if out := c.InOrStdin(); out != os.Stdin {
t.Errorf("Expected setting input to nil to revert back to stdin")
}
}

func TestFlagErrorFunc(t *testing.T) {
c := &Command{Use: "c", Run: emptyRun}

Expand Down

0 comments on commit e35034f

Please sign in to comment.