Skip to content

Commit

Permalink
fixed test.
Browse files Browse the repository at this point in the history
  • Loading branch information
Marian Craciunescu committed Mar 22, 2017
1 parent 2436b5d commit 848b70b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
10 changes: 10 additions & 0 deletions server/apns/apns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/sideshow/apns2"
"github.com/stretchr/testify/assert"
"testing"
"time"
)

var ErrSendRandomError = errors.New("A Sender error")
Expand Down Expand Up @@ -42,11 +43,18 @@ func TestConn_HandleResponseOnSendError(t *testing.T) {
_, finish := testutil.NewMockCtrl(t)
defer finish()
a := assert.New(t)
defer testutil.EnableDebugForMethod() ()

//given
c, _ := newAPNSConnector(t)
mRequest := NewMockRequest(testutil.MockCtrl)
message := &protocol.Message{
HeaderJSON:`{"Correlation-Id": "7sdks723ksgqn"}`,
ID: 42,
}
mRequest.EXPECT().Message().Return(message)

time.Sleep(100*time.Millisecond)
//when
err := c.HandleResponse(mRequest, nil, nil, ErrSendRandomError)

Expand All @@ -72,6 +80,7 @@ func TestConn_HandleResponse(t *testing.T) {

message := &protocol.Message{
ID: 42,
HeaderJSON:`{"Content-Type": "text/plain", "Correlation-Id": "7sdks723ksgqn"}`,
}
mRequest := NewMockRequest(testutil.MockCtrl)
mRequest.EXPECT().Message().Return(message).AnyTimes()
Expand Down Expand Up @@ -106,6 +115,7 @@ func TestNew_HandleResponseHandleSubscriber(t *testing.T) {
for _, reason := range removeForReasons {
message := &protocol.Message{
ID: 42,
HeaderJSON:`{"Correlation-Id": "7sdks723ksgqn"}`,
}
mSubscriber := NewMockSubscriber(testutil.MockCtrl)
mSubscriber.EXPECT().SetLastID(gomock.Any())
Expand Down
3 changes: 3 additions & 0 deletions server/fcm/fcm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ func TestConnector_GetErrorMessageFromFCM(t *testing.T) {
ID: uint64(4),
Path: "/topic",
Body: []byte("{id:id}"),
HeaderJSON:`{"Correlation-Id": "7sdks723ksgqn"}`,
}, true)

// wait before closing the FCM connector
Expand Down Expand Up @@ -120,6 +121,7 @@ func TestFCMFormatMessage(t *testing.T) {
Path: "/topic",
ID: 1,
Body: []byte(fullFCMMessage),
HeaderJSON:`{"Correlation-Id": "7sdks723ksgqn"}`,
}

if !a.NotNil(subRoute) {
Expand Down Expand Up @@ -158,6 +160,7 @@ func TestFCMFormatMessage(t *testing.T) {
Path: "/topic",
ID: 1,
Body: []byte(`plain body`),
HeaderJSON:`{"Correlation-Id": "7sdks723ksgqn"}`,
}

mocks.gcmSender.EXPECT().Send(gomock.Any()).Do(func(m *gcm.Message) (*gcm.Response, error) {
Expand Down

0 comments on commit 848b70b

Please sign in to comment.