server_v2.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. // +build ignore
  2. package mock
  3. import (
  4. "net/http"
  5. "github.com/coreos/etcd/store"
  6. "github.com/coreos/etcd/third_party/github.com/goraft/raft"
  7. "github.com/stretchr/testify/mock"
  8. )
  9. // A mock Server for the v2 handlers.
  10. type ServerV2 struct {
  11. mock.Mock
  12. store store.Store
  13. }
  14. func NewServerV2(store store.Store) *ServerV2 {
  15. return &ServerV2{
  16. store: store,
  17. }
  18. }
  19. func (s *ServerV2) State() string {
  20. args := s.Called()
  21. return args.String(0)
  22. }
  23. func (s *ServerV2) Leader() string {
  24. args := s.Called()
  25. return args.String(0)
  26. }
  27. func (s *ServerV2) CommitIndex() uint64 {
  28. args := s.Called()
  29. return args.Get(0).(uint64)
  30. }
  31. func (s *ServerV2) Term() uint64 {
  32. args := s.Called()
  33. return args.Get(0).(uint64)
  34. }
  35. func (s *ServerV2) PeerURL(name string) (string, bool) {
  36. args := s.Called(name)
  37. return args.String(0), args.Bool(1)
  38. }
  39. func (s *ServerV2) ClientURL(name string) (string, bool) {
  40. args := s.Called(name)
  41. return args.String(0), args.Bool(1)
  42. }
  43. func (s *ServerV2) Store() store.Store {
  44. return s.store
  45. }
  46. func (s *ServerV2) Dispatch(c raft.Command, w http.ResponseWriter, req *http.Request) error {
  47. args := s.Called(c, w, req)
  48. return args.Error(0)
  49. }