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