app_test.go 446 B

1234567891011121314151617181920212223242526
  1. package cmd
  2. import (
  3. "bytes"
  4. "github.com/urfave/cli/v2"
  5. "io"
  6. "log"
  7. "os"
  8. "testing"
  9. )
  10. // This only contains helpers so far
  11. func TestMain(m *testing.M) {
  12. log.SetOutput(io.Discard)
  13. os.Exit(m.Run())
  14. }
  15. func newTestApp() (*cli.App, *bytes.Buffer, *bytes.Buffer, *bytes.Buffer) {
  16. var stdin, stdout, stderr bytes.Buffer
  17. app := New()
  18. app.Reader = &stdin
  19. app.Writer = &stdout
  20. app.ErrWriter = &stderr
  21. return app, &stdin, &stdout, &stderr
  22. }