Skip to content

Commit

Permalink
Some service remote tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
cscatolini committed Apr 12, 2018
1 parent 56661aa commit eb74d5e
Show file tree
Hide file tree
Showing 3 changed files with 405 additions and 10 deletions.
198 changes: 198 additions & 0 deletions cluster/mocks/rpc.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 5 additions & 10 deletions service/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ func (m *MyComp) Handler2(ss *session.Session, b []byte) ([]byte, error) {
return nil, nil
}

type NoHandlerComp struct {
type NoHandlerRemoteComp struct {
component.Base
}

func (m *NoHandlerComp) Init() {}
func (m *NoHandlerComp) Shutdown() {}
func (m *NoHandlerRemoteComp) Init() {}
func (m *NoHandlerRemoteComp) Shutdown() {}

func TestNewHandlerService(t *testing.T) {
dieChan := make(chan bool)
Expand All @@ -61,10 +61,6 @@ func TestNewHandlerService(t *testing.T) {
mockSerializer := mocks.NewMockSerializer(ctrl)
heartbeatTimeout := 1 * time.Second
sv := &cluster.Server{}
// ID: "id1",
// Type: "type1",
// Frontend: true,
// }
remoteSvc := &RemoteService{}
svc := NewHandlerService(
dieChan,
Expand All @@ -84,7 +80,6 @@ func TestNewHandlerService(t *testing.T) {
assert.Equal(t, mockSerializer, svc.serializer)
assert.Equal(t, heartbeatTimeout, svc.heartbeatTimeout)
assert.Equal(t, 10, svc.messagesBufferSize)
assert.Equal(t, mockSerializer, svc.serializer)
assert.Equal(t, sv, svc.server)
assert.Equal(t, remoteSvc, svc.remoteService)
assert.NotNil(t, svc.chLocalProcess)
Expand Down Expand Up @@ -119,8 +114,8 @@ func TestHandlerServiceRegisterFailsIfRegisterTwice(t *testing.T) {

func TestHandlerServiceRegisterFailsIfNoHandlerMethods(t *testing.T) {
svc := NewHandlerService(nil, nil, nil, nil, 0, 0, 0, 0, nil, nil)
err := svc.Register(&NoHandlerComp{}, []component.Option{})
assert.Equal(t, errors.New("type NoHandlerComp has no exported methods of suitable type"), err)
err := svc.Register(&NoHandlerRemoteComp{}, []component.Option{})
assert.Equal(t, errors.New("type NoHandlerRemoteComp has no exported methods of suitable type"), err)
}

func TestHandlerServiceProcessMessage(t *testing.T) {
Expand Down
Loading

0 comments on commit eb74d5e

Please sign in to comment.