Skip to content

Commit 2a8a507

Browse files
committed
test/fix: fix tests that failed due to multiple appearence of version componant in path
1 parent c2d85f0 commit 2a8a507

File tree

12 files changed

+25
-20
lines changed

12 files changed

+25
-20
lines changed

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)

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")
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()) {

voice/recording.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ func ReadRecording(c *messagebird.Client, callID, legID, id string) (*Recording,
7272
Data []*Recording `json:"data"`
7373
})
7474

75-
if err := c.Request(json, http.MethodGet, fmt.Sprintf("%s/v1/calls/%s/legs/%s/recordings/%s",
75+
if err := c.Request(json, http.MethodGet, fmt.Sprintf("%s/calls/%s/legs/%s/recordings/%s",
7676
apiRoot, callID, legID, id), nil); err != nil {
7777
return nil, err
7878
}
@@ -82,7 +82,7 @@ func ReadRecording(c *messagebird.Client, callID, legID, id string) (*Recording,
8282

8383
// Recordings returns a Paginator which iterates over Recordings.
8484
func Recordings(c *messagebird.Client, callID, legID string) *Paginator {
85-
return newPaginator(c, fmt.Sprintf("%s/v1/calls/%s/legs/%s/recordings", apiRoot, callID,
85+
return newPaginator(c, fmt.Sprintf("%s/calls/%s/legs/%s/recordings", apiRoot, callID,
8686
legID), reflect.TypeOf(Recording{}))
8787
}
8888

@@ -111,7 +111,7 @@ func (rec *Recording) Transcriptions(client *messagebird.Client, callID string)
111111

112112
// Delete deletes a recording.
113113
func Delete(client *messagebird.Client, callID, legID, recordingID string) error {
114-
return client.Request(nil, http.MethodDelete, fmt.Sprintf("%s/v1/calls/%s/legs/%s/recordings/%s", apiRoot, callID, legID, recordingID), nil)
114+
return client.Request(nil, http.MethodDelete, fmt.Sprintf("%s/calls/%s/legs/%s/recordings/%s", apiRoot, callID, legID, recordingID), nil)
115115
}
116116

117117
// DownloadFile streams the recorded WAV file.

voice/recording_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,14 @@ func TestRecordingGetFile(t *testing.T) {
3636

3737
func TestDelete(t *testing.T) {
3838
mbtest.WillReturn([]byte(""), http.StatusNoContent)
39-
client := mbtest.Client(t)
39+
client := mbtest.Client(t)
4040
if err := Delete(client, "callid", "legid", "recid"); err != nil {
4141
t.Errorf("unexpected error while deleting recording: %s", err)
4242
}
4343

4444
mbtest.AssertEndpointCalled(t, http.MethodDelete, "/v1/calls/callid/legs/legid/recordings/recid")
4545
}
4646

47-
4847
func TestReadRecording(t *testing.T) {
4948
mbtest.WillReturnTestdata(t, "recordingObject.json", http.StatusOK)
5049
client := mbtest.Client(t)

0 commit comments

Comments
 (0)