mirror of
https://github.com/planetmint/planetmint-go.git
synced 2025-03-30 15:08:28 +00:00
33 lines
448 B
Go
33 lines
448 B
Go
package testutil
|
|
|
|
import (
|
|
"bytes"
|
|
"io"
|
|
"strings"
|
|
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
type BufferReader interface {
|
|
io.Reader
|
|
Reset(string)
|
|
}
|
|
|
|
type BufferWriter interface {
|
|
io.Writer
|
|
Reset()
|
|
Bytes() []byte
|
|
String() string
|
|
}
|
|
|
|
func ApplyMockIO(c *cobra.Command) (BufferReader, BufferWriter) {
|
|
mockIn := strings.NewReader("")
|
|
mockOut := bytes.NewBufferString("")
|
|
|
|
c.SetIn(mockIn)
|
|
c.SetOut(mockOut)
|
|
c.SetErr(mockOut)
|
|
|
|
return mockIn, mockOut
|
|
}
|