Make FCM client interface private

This commit is contained in:
Eugene 2017-10-11 16:59:58 +03:00 committed by Evgeny Danienko
parent c304d3e7ae
commit 390495342c
No known key found for this signature in database
GPG Key ID: BC8C34D8B45BECBF
4 changed files with 26 additions and 26 deletions

View File

@ -2,8 +2,8 @@ package fcm
import "github.com/NaySoftware/go-fcm" import "github.com/NaySoftware/go-fcm"
// FirebaseClient is a copy of "go-fcm" client methods. // firebaseClient is a copy of "go-fcm" client methods.
type FirebaseClient interface { type firebaseClient interface {
NewFcmRegIdsMsg(tokens []string, body interface{}) *fcm.FcmClient NewFcmRegIdsMsg(tokens []string, body interface{}) *fcm.FcmClient
Send() (*fcm.FcmResponseStatus, error) Send() (*fcm.FcmResponseStatus, error)
SetNotificationPayload(payload *fcm.NotificationPayload) *fcm.FcmClient SetNotificationPayload(payload *fcm.NotificationPayload) *fcm.FcmClient

View File

@ -10,43 +10,43 @@ import (
reflect "reflect" reflect "reflect"
) )
// MockFirebaseClient is a mock of FirebaseClient interface // MockfirebaseClient is a mock of firebaseClient interface
type MockFirebaseClient struct { type MockfirebaseClient struct {
ctrl *gomock.Controller ctrl *gomock.Controller
recorder *MockFirebaseClientMockRecorder recorder *MockfirebaseClientMockRecorder
} }
// MockFirebaseClientMockRecorder is the mock recorder for MockFirebaseClient // MockfirebaseClientMockRecorder is the mock recorder for MockfirebaseClient
type MockFirebaseClientMockRecorder struct { type MockfirebaseClientMockRecorder struct {
mock *MockFirebaseClient mock *MockfirebaseClient
} }
// NewMockFirebaseClient creates a new mock instance // NewMockfirebaseClient creates a new mock instance
func NewMockFirebaseClient(ctrl *gomock.Controller) *MockFirebaseClient { func NewMockfirebaseClient(ctrl *gomock.Controller) *MockfirebaseClient {
mock := &MockFirebaseClient{ctrl: ctrl} mock := &MockfirebaseClient{ctrl: ctrl}
mock.recorder = &MockFirebaseClientMockRecorder{mock} mock.recorder = &MockfirebaseClientMockRecorder{mock}
return mock return mock
} }
// EXPECT returns an object that allows the caller to indicate expected use // EXPECT returns an object that allows the caller to indicate expected use
func (m *MockFirebaseClient) EXPECT() *MockFirebaseClientMockRecorder { func (m *MockfirebaseClient) EXPECT() *MockfirebaseClientMockRecorder {
return m.recorder return m.recorder
} }
// NewFcmRegIdsMsg mocks base method // NewFcmRegIdsMsg mocks base method
func (m *MockFirebaseClient) NewFcmRegIdsMsg(tokens []string, body interface{}) *go_fcm.FcmClient { func (m *MockfirebaseClient) NewFcmRegIdsMsg(tokens []string, body interface{}) *go_fcm.FcmClient {
ret := m.ctrl.Call(m, "NewFcmRegIdsMsg", tokens, body) ret := m.ctrl.Call(m, "NewFcmRegIdsMsg", tokens, body)
ret0, _ := ret[0].(*go_fcm.FcmClient) ret0, _ := ret[0].(*go_fcm.FcmClient)
return ret0 return ret0
} }
// NewFcmRegIdsMsg indicates an expected call of NewFcmRegIdsMsg // NewFcmRegIdsMsg indicates an expected call of NewFcmRegIdsMsg
func (mr *MockFirebaseClientMockRecorder) NewFcmRegIdsMsg(tokens, body interface{}) *gomock.Call { func (mr *MockfirebaseClientMockRecorder) NewFcmRegIdsMsg(tokens, body interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NewFcmRegIdsMsg", reflect.TypeOf((*MockFirebaseClient)(nil).NewFcmRegIdsMsg), tokens, body) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NewFcmRegIdsMsg", reflect.TypeOf((*MockfirebaseClient)(nil).NewFcmRegIdsMsg), tokens, body)
} }
// Send mocks base method // Send mocks base method
func (m *MockFirebaseClient) Send() (*go_fcm.FcmResponseStatus, error) { func (m *MockfirebaseClient) Send() (*go_fcm.FcmResponseStatus, error) {
ret := m.ctrl.Call(m, "Send") ret := m.ctrl.Call(m, "Send")
ret0, _ := ret[0].(*go_fcm.FcmResponseStatus) ret0, _ := ret[0].(*go_fcm.FcmResponseStatus)
ret1, _ := ret[1].(error) ret1, _ := ret[1].(error)
@ -54,18 +54,18 @@ func (m *MockFirebaseClient) Send() (*go_fcm.FcmResponseStatus, error) {
} }
// Send indicates an expected call of Send // Send indicates an expected call of Send
func (mr *MockFirebaseClientMockRecorder) Send() *gomock.Call { func (mr *MockfirebaseClientMockRecorder) Send() *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Send", reflect.TypeOf((*MockFirebaseClient)(nil).Send)) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Send", reflect.TypeOf((*MockfirebaseClient)(nil).Send))
} }
// SetNotificationPayload mocks base method // SetNotificationPayload mocks base method
func (m *MockFirebaseClient) SetNotificationPayload(payload *go_fcm.NotificationPayload) *go_fcm.FcmClient { func (m *MockfirebaseClient) SetNotificationPayload(payload *go_fcm.NotificationPayload) *go_fcm.FcmClient {
ret := m.ctrl.Call(m, "SetNotificationPayload", payload) ret := m.ctrl.Call(m, "SetNotificationPayload", payload)
ret0, _ := ret[0].(*go_fcm.FcmClient) ret0, _ := ret[0].(*go_fcm.FcmClient)
return ret0 return ret0
} }
// SetNotificationPayload indicates an expected call of SetNotificationPayload // SetNotificationPayload indicates an expected call of SetNotificationPayload
func (mr *MockFirebaseClientMockRecorder) SetNotificationPayload(payload interface{}) *gomock.Call { func (mr *MockfirebaseClientMockRecorder) SetNotificationPayload(payload interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetNotificationPayload", reflect.TypeOf((*MockFirebaseClient)(nil).SetNotificationPayload), payload) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetNotificationPayload", reflect.TypeOf((*MockfirebaseClient)(nil).SetNotificationPayload), payload)
} }

View File

@ -7,7 +7,7 @@ import (
// Notifier represents messaging provider for notifications. // Notifier represents messaging provider for notifications.
type Notifier struct { type Notifier struct {
FirebaseClient firebaseClient
} }
// NewNotifier Firebase Cloud Messaging client constructor. // NewNotifier Firebase Cloud Messaging client constructor.
@ -23,7 +23,7 @@ func (p *Notifier) Notify(body interface{}, tokens ...string) error {
}) })
p.setMessage(body, tokens...) p.setMessage(body, tokens...)
_, err := p.FirebaseClient.Send() _, err := p.firebaseClient.Send()
return err return err
} }

View File

@ -17,13 +17,13 @@ func TestFCMClientTestSuite(t *testing.T) {
type NotifierTestSuite struct { type NotifierTestSuite struct {
t.BaseTestSuite t.BaseTestSuite
fcmClientMock *MockFirebaseClient fcmClientMock *MockfirebaseClient
fcmClientMockCtrl *gomock.Controller fcmClientMockCtrl *gomock.Controller
} }
func (s *NotifierTestSuite) SetupTest() { func (s *NotifierTestSuite) SetupTest() {
s.fcmClientMockCtrl = gomock.NewController(s.T()) s.fcmClientMockCtrl = gomock.NewController(s.T())
s.fcmClientMock = NewMockFirebaseClient(s.fcmClientMockCtrl) s.fcmClientMock = NewMockfirebaseClient(s.fcmClientMockCtrl)
} }
func (s *NotifierTestSuite) TearDownTest() { func (s *NotifierTestSuite) TearDownTest() {