github.com/jpetazzo/etcd@v0.2.1-0.20140113055439-97f1363afac5/tests/mock/server_v2.go (about)

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