mock_store.go 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. package mock
  2. import (
  3. "time"
  4. "github.com/coreos/etcd/store"
  5. "github.com/stretchr/testify/mock"
  6. )
  7. // A mock Store object used for testing.
  8. type Store struct {
  9. mock.Mock
  10. }
  11. func NewStore() *Store {
  12. return &Store{}
  13. }
  14. func (s *Store) Get(nodePath string, recursive, sorted bool, index uint64, term uint64) (*store.Event, error) {
  15. args := s.Called(nodePath, recursive, sorted, index, term)
  16. return args.Get(0).(*store.Event), args.Error(1)
  17. }
  18. func (s *Store) Set(nodePath string, value string, expireTime time.Time, index uint64, term uint64) (*store.Event, error) {
  19. args := s.Called(nodePath, value, expireTime, index, term)
  20. return args.Get(0).(*store.Event), args.Error(1)
  21. }
  22. func (s *Store) Update(nodePath string, newValue string, expireTime time.Time, index uint64, term uint64) (*store.Event, error) {
  23. args := s.Called(nodePath, newValue, expireTime, index, term)
  24. return args.Get(0).(*store.Event), args.Error(1)
  25. }
  26. func (s *Store) Create(nodePath string, value string, incrementalSuffix bool, expireTime time.Time, index uint64, term uint64) (*store.Event, error) {
  27. args := s.Called(nodePath, value, incrementalSuffix, expireTime, index, term)
  28. return args.Get(0).(*store.Event), args.Error(1)
  29. }
  30. func (s *Store) CompareAndSwap(nodePath string, prevValue string, prevIndex uint64, value string, expireTime time.Time, index uint64, term uint64) (*store.Event, error) {
  31. args := s.Called(nodePath, prevValue, prevIndex, value, expireTime, index, term)
  32. return args.Get(0).(*store.Event), args.Error(1)
  33. }
  34. func (s *Store) Delete(nodePath string, recursive bool, index uint64, term uint64) (*store.Event, error) {
  35. args := s.Called(nodePath, recursive, index, term)
  36. return args.Get(0).(*store.Event), args.Error(1)
  37. }
  38. func (s *Store) Watch(prefix string, recursive bool, sinceIndex uint64, index uint64, term uint64) (<-chan *store.Event, error) {
  39. args := s.Called(prefix, recursive, sinceIndex, index, term)
  40. return args.Get(0).(<-chan *store.Event), args.Error(1)
  41. }
  42. func (s *Store) Save() ([]byte, error) {
  43. args := s.Called()
  44. return args.Get(0).([]byte), args.Error(1)
  45. }
  46. func (s *Store) Recovery(b []byte) error {
  47. args := s.Called(b)
  48. return args.Error(1)
  49. }
  50. func (s *Store) JsonStats() []byte {
  51. args := s.Called()
  52. return args.Get(0).([]byte)
  53. }