forked from etcd-io/etcd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server_v2.go
60 lines (48 loc) · 1.12 KB
/
server_v2.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 mock
import (
"net/http"
"github.com/coreos/etcd/store"
"github.com/coreos/etcd/third_party/github.com/goraft/raft"
"github.com/stretchr/testify/mock"
)
// A mock Server for the v2 handlers.
type ServerV2 struct {
mock.Mock
store store.Store
}
func NewServerV2(store store.Store) *ServerV2 {
return &ServerV2{
store: store,
}
}
func (s *ServerV2) State() string {
args := s.Called()
return args.String(0)
}
func (s *ServerV2) Leader() string {
args := s.Called()
return args.String(0)
}
func (s *ServerV2) CommitIndex() uint64 {
args := s.Called()
return args.Get(0).(uint64)
}
func (s *ServerV2) Term() uint64 {
args := s.Called()
return args.Get(0).(uint64)
}
func (s *ServerV2) PeerURL(name string) (string, bool) {
args := s.Called(name)
return args.String(0), args.Bool(1)
}
func (s *ServerV2) ClientURL(name string) (string, bool) {
args := s.Called(name)
return args.String(0), args.Bool(1)
}
func (s *ServerV2) Store() store.Store {
return s.store
}
func (s *ServerV2) Dispatch(c raft.Command, w http.ResponseWriter, req *http.Request) error {
args := s.Called(c, w, req)
return args.Error(0)
}