Skip to content

Commit 23b045e

Browse files
author
Artur Khabibullin
authored
Merge pull request #85 from sarathsp06/master
fix: fix failing tests and update travis
2 parents c2d85f0 + 2db5a60 commit 23b045e

14 files changed

+28
-22
lines changed

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
language: go
2+
go_import_path: github.com/messagebird/go-rest-api
23
go:
3-
- "1.12"
44
- "1.13"
5+
- "1.14"
56
- stable
67
- master
78
matrix:

contact/contact_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,10 @@ func TestListPagination(t *testing.T) {
139139
}
140140

141141
for _, tc := range tt {
142-
List(client, tc.options)
142+
_, err := List(client, tc.options)
143+
if err != nil {
144+
t.Fatalf("unexpected error listing contacts: %s", err)
145+
}
143146

144147
if query := mbtest.Request.URL.RawQuery; query != tc.expected {
145148
t.Fatalf("expected %s, got %s", tc.expected, query)

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module github.com/messagebird/go-rest-api
22

3-
go 1.12
3+
go 1.13

group/group_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,10 @@ func TestListPagination(t *testing.T) {
101101
}
102102

103103
for _, tc := range tt {
104-
List(client, tc.options)
105-
104+
_, err := List(client, tc.options)
105+
if err != nil {
106+
t.Fatalf("unexpected error listing groups: %s", err)
107+
}
106108
if query := mbtest.Request.URL.RawQuery; query != tc.expected {
107109
t.Fatalf("got %s, expected %s", tc.expected, query)
108110
}

number/number_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ func TestUpdate(t *testing.T) {
9999

100100
mbtest.AssertEndpointCalled(t, http.MethodPatch, "/v1/phone-numbers/31612345670")
101101
mbtest.AssertTestdata(t, "numberUpdateRequestObject.json", mbtest.Request.Body)
102-
102+
103103
if !reflect.DeepEqual(number.Tags, []string{"tag1", "tag2", "tag3"}) {
104104
t.Errorf("Unexpected number tags: %s, expected: ['tag1', 'tag2', 'tag3']", number.Tags)
105105
}

signature/signature.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ func (v *Validator) ValidRequest(r *http.Request) error {
117117
return fmt.Errorf("Unknown host: %s", r.Host)
118118
}
119119
b, _ := ioutil.ReadAll(r.Body)
120-
if v.validTimestamp(ts) == false || v.validSignature(ts, r.URL.RawQuery, b, rs) == false {
120+
if !v.validTimestamp(ts) || !v.validSignature(ts, r.URL.RawQuery, b, rs) {
121121
return fmt.Errorf("Unknown host: %s", r.Host)
122122
}
123123
r.Body = ioutil.NopCloser(bytes.NewBuffer(b))

signature/signature_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,7 @@ func TestCalculateSignature(t *testing.T) {
8080
t.Errorf("Error calculating signature: %s, expected: %s", s, tt.es)
8181
}
8282
drs, _ := base64.StdEncoding.DecodeString(tt.es)
83-
e := bool(bytes.Compare(s, drs) == 0)
84-
if e != tt.e {
83+
if bytes.Equal(s, drs) != tt.e {
8584
t.Errorf("Unexpected signature: %s, test case: %s", s, tt.name)
8685
}
8786
}

sms/message_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,9 @@ func TestListScheduled(t *testing.T) {
315315
if !strings.Contains(r.URL.String(), expectedStatusFilter) {
316316
t.Errorf("API call should contain filter by status (%v), but is is not %v", expectedStatusFilter, r.URL.String())
317317
}
318-
w.Write(mbtest.Testdata(t, "messageListScheduledObject.json"))
318+
if _, err := w.Write(mbtest.Testdata(t, "messageListScheduledObject.json")); err != nil {
319+
t.Fatalf("unexpected error responding to list scheduled request. err: %s", err)
320+
}
319321
})
320322
transport, teardown := mbtest.HTTPTestTransport(h)
321323
defer teardown()

voice/callflow_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ func TestCallFlowJSONMarshal(t *testing.T) {
5757
Length: time.Second * 10,
5858
},
5959
&CallFlowRecordStep{
60-
CallFlowStepBase: CallFlowStepBase{
60+
CallFlowStepBase: CallFlowStepBase{
6161
ID: "3",
6262
},
6363
MaxLength: 10,
@@ -143,7 +143,7 @@ func TestCallFlowJSONUnmarshal(t *testing.T) {
143143
Length: time.Second * 10,
144144
},
145145
&CallFlowRecordStep{
146-
CallFlowStepBase: CallFlowStepBase{
146+
CallFlowStepBase: CallFlowStepBase{
147147
ID: "3",
148148
},
149149
MaxLength: 10,
@@ -186,7 +186,7 @@ func TestCreateCallFlow(t *testing.T) {
186186
Length: time.Second,
187187
},
188188
&CallFlowRecordStep{
189-
CallFlowStepBase: CallFlowStepBase{
189+
CallFlowStepBase: CallFlowStepBase{
190190
ID: "3",
191191
},
192192
MaxLength: 10,

voice/main_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"os"
1010
"testing"
1111

12-
"github.com/messagebird/go-rest-api"
12+
messagebird "github.com/messagebird/go-rest-api"
1313
)
1414

1515
func testRequest(status int, body []byte) (*messagebird.Client, func()) {

0 commit comments

Comments
 (0)