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