forked from compose/transporter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
testing.go
52 lines (41 loc) · 1.45 KB
/
testing.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
package adaptor
import (
"sync"
"github.com/compose/transporter/client"
)
var (
_ Adaptor = &Mock{}
_ Adaptor = &UnsupportedMock{}
)
// Mock can be used for mocking tests that need no functional client interfaces.
type Mock struct {
BaseConfig
}
// Client satisfies the V2 interface for providing a client.Client.
func (m *Mock) Client() (client.Client, error) {
return &client.Mock{}, nil
}
// Reader satisfies the V2 interface for providing a client.Reader.
func (m *Mock) Reader() (client.Reader, error) {
return &client.MockReader{}, nil
}
// Writer satisfies the V2 interface for providing a client.Writer.
func (m *Mock) Writer(chan struct{}, *sync.WaitGroup) (client.Writer, error) {
return &client.MockWriter{}, nil
}
// UnsupportedMock can be used for mocking tests that need no functional client interfaces.
type UnsupportedMock struct {
BaseConfig
}
// Client satisfies the V2 interface for providing a client.Client.
func (m *UnsupportedMock) Client() (client.Client, error) {
return nil, ErrFuncNotSupported{"unsupported", "Client()"}
}
// Reader satisfies the V2 interface for providing a client.Reader.
func (m *UnsupportedMock) Reader() (client.Reader, error) {
return nil, ErrFuncNotSupported{"unsupported", "Reader()"}
}
// Writer satisfies the V2 interface for providing a client.Writer.
func (m *UnsupportedMock) Writer(chan struct{}, *sync.WaitGroup) (client.Writer, error) {
return nil, ErrFuncNotSupported{"unsupported", "Writer()"}
}