blob: bc18b27e81cf68300fcfcd99311d0300bf0fc77d (
plain) (
blame)
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
|
package common
import (
"bytes"
"io"
gogitioutil "github.com/go-git/go-git/v5/utils/ioutil"
"github.com/go-git/go-git/v5/plumbing/transport"
)
type MockCommand struct {
stdin bytes.Buffer
stdout bytes.Buffer
stderr bytes.Buffer
}
func (c MockCommand) StderrPipe() (io.Reader, error) {
return &c.stderr, nil
}
func (c MockCommand) StdinPipe() (io.WriteCloser, error) {
return gogitioutil.WriteNopCloser(&c.stdin), nil
}
func (c MockCommand) StdoutPipe() (io.Reader, error) {
return &c.stdout, nil
}
func (c MockCommand) Start() error {
return nil
}
func (c MockCommand) Close() error {
panic("not implemented")
}
type MockCommander struct {
stderr string
}
func (c MockCommander) Command(cmd string, ep *transport.Endpoint, auth transport.AuthMethod) (Command, error) {
return &MockCommand{
stderr: *bytes.NewBufferString(c.stderr),
}, nil
}
|