-
Notifications
You must be signed in to change notification settings - Fork 2
/
mock_exec_io.go
60 lines (48 loc) · 1.02 KB
/
mock_exec_io.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package mocks
import (
"io"
"github.com/virtual-kubelet/virtual-kubelet/node/api"
)
type MockExecIO struct {
tty bool
input io.Reader
output io.WriteCloser
err io.WriteCloser
chResize chan api.TermSize
}
func NewMockExecIO(tty bool, input io.Reader, output io.WriteCloser, err io.WriteCloser, chResize chan api.TermSize) *MockExecIO {
return &MockExecIO{
tty: tty,
input: input,
output: output,
err: err,
chResize: chResize,
}
}
func (e *MockExecIO) TTY() bool {
return e.tty
}
func (e *MockExecIO) Stdin() io.Reader {
return e.input
}
func (e *MockExecIO) Stdout() io.WriteCloser {
return e.output
}
func (e *MockExecIO) Stderr() io.WriteCloser {
return e.err
}
func (e *MockExecIO) Resize() <-chan api.TermSize {
return e.chResize
}
type MockWriterCloser struct {
Data []byte
isClosed bool
}
func (w *MockWriterCloser) Write(p []byte) (n int, err error) {
w.Data = append(w.Data, p...)
return
}
func (w *MockWriterCloser) Close() error {
w.isClosed = true
return nil
}