-
Notifications
You must be signed in to change notification settings - Fork 78
Expand file tree
/
Copy pathmockdriver_test.go
More file actions
42 lines (32 loc) · 814 Bytes
/
mockdriver_test.go
File metadata and controls
42 lines (32 loc) · 814 Bytes
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
package dcron_test
import (
"context"
"github.com/dcron-contrib/commons"
)
// This is a mock driver used for unit test.
type MockDriver struct {
StartFunc func(context.Context) error
GetNodesFunc func(context.Context) ([]string, error)
}
func (md *MockDriver) Init(serviceName string, opts ...commons.Option) {}
func (md *MockDriver) NodeID() string {
return ""
}
func (md *MockDriver) GetNodes(ctx context.Context) (nodes []string, err error) {
if md.GetNodesFunc != nil {
return md.GetNodesFunc(ctx)
}
return
}
func (md *MockDriver) Start(ctx context.Context) (err error) {
if md.StartFunc != nil {
return md.StartFunc(ctx)
}
return
}
func (md *MockDriver) Stop(ctx context.Context) (err error) {
return
}
func (md *MockDriver) WithOption(opt commons.Option) (err error) {
return
}