Skip to content

Commit e53d897

Browse files
committed
Rename messagebirdtest to mbtest in group_test.go
1 parent 977d7e4 commit e53d897

File tree

1 file changed

+34
-34
lines changed

1 file changed

+34
-34
lines changed

group/group_test.go

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -5,52 +5,52 @@ import (
55
"testing"
66
"time"
77

8-
"github.com/messagebird/go-rest-api/internal/messagebirdtest"
8+
"github.com/messagebird/go-rest-api/mbtest"
99
)
1010

1111
func TestMain(m *testing.M) {
12-
messagebirdtest.EnableServer(m)
12+
mbtest.EnableServer(m)
1313
}
1414

1515
func TestCreate(t *testing.T) {
16-
messagebirdtest.WillReturnTestdata(t, "groupObject.json", http.StatusCreated)
17-
client := messagebirdtest.Client(t)
16+
mbtest.WillReturnTestdata(t, "groupObject.json", http.StatusCreated)
17+
client := mbtest.Client(t)
1818

1919
group, err := Create(client, &Request{"Friends"})
2020
if err != nil {
2121
t.Fatalf("unexpected error creating Group: %s", err)
2222
}
2323

24-
messagebirdtest.AssertEndpointCalled(t, http.MethodPost, "/groups")
25-
messagebirdtest.AssertTestdata(t, "groupRequestCreateObject.json", messagebirdtest.Request.Body)
24+
mbtest.AssertEndpointCalled(t, http.MethodPost, "/groups")
25+
mbtest.AssertTestdata(t, "groupRequestCreateObject.json", messagebirdtest.Request.Body)
2626

2727
if group.Name != "Friends" {
2828
t.Fatalf("expected Friends, got %s", group.Name)
2929
}
3030
}
3131

3232
func TestCreateWithEmptyName(t *testing.T) {
33-
client := messagebirdtest.Client(t)
33+
client := mbtest.Client(t)
3434

3535
if _, err := Create(client, &Request{""}); err == nil {
3636
t.Fatalf("expected error, got nil")
3737
}
3838
}
3939

4040
func TestDelete(t *testing.T) {
41-
messagebirdtest.WillReturn([]byte(""), http.StatusNoContent)
42-
client := messagebirdtest.Client(t)
41+
mbtest.WillReturn([]byte(""), http.StatusNoContent)
42+
client := mbtest.Client(t)
4343

4444
if err := Delete(client, "group-id"); err != nil {
4545
t.Fatalf("unexpected error deleting Group: %s", err)
4646
}
4747

48-
messagebirdtest.AssertEndpointCalled(t, http.MethodDelete, "/groups/group-id")
48+
mbtest.AssertEndpointCalled(t, http.MethodDelete, "/groups/group-id")
4949
}
5050

5151
func TestList(t *testing.T) {
52-
messagebirdtest.WillReturnTestdata(t, "groupListObject.json", http.StatusOK)
53-
client := messagebirdtest.Client(t)
52+
mbtest.WillReturnTestdata(t, "groupListObject.json", http.StatusOK)
53+
client := mbtest.Client(t)
5454

5555
list, err := List(client, DefaultListOptions)
5656
if err != nil {
@@ -85,11 +85,11 @@ func TestList(t *testing.T) {
8585
t.Fatalf("expected second-id, got %s", list.Items[1].ID)
8686
}
8787

88-
messagebirdtest.AssertEndpointCalled(t, http.MethodGet, "/groups")
88+
mbtest.AssertEndpointCalled(t, http.MethodGet, "/groups")
8989
}
9090

9191
func TestListPagination(t *testing.T) {
92-
client := messagebirdtest.Client(t)
92+
client := mbtest.Client(t)
9393

9494
tt := []struct {
9595
expected string
@@ -103,22 +103,22 @@ func TestListPagination(t *testing.T) {
103103
for _, tc := range tt {
104104
List(client, tc.options)
105105

106-
if query := messagebirdtest.Request.URL.RawQuery; query != tc.expected {
106+
if query := mbtest.Request.URL.RawQuery; query != tc.expected {
107107
t.Fatalf("expected %s, got %s", tc.expected, query)
108108
}
109109
}
110110
}
111111

112112
func TestRead(t *testing.T) {
113-
messagebirdtest.WillReturnTestdata(t, "groupObject.json", http.StatusOK)
114-
client := messagebirdtest.Client(t)
113+
mbtest.WillReturnTestdata(t, "groupObject.json", http.StatusOK)
114+
client := mbtest.Client(t)
115115

116116
group, err := Read(client, "group-id")
117117
if err != nil {
118118
t.Fatalf("unexpected error reading Group: %s", err)
119119
}
120120

121-
messagebirdtest.AssertEndpointCalled(t, http.MethodGet, "/groups/group-id")
121+
mbtest.AssertEndpointCalled(t, http.MethodGet, "/groups/group-id")
122122

123123
if group.ID != "group-id" {
124124
t.Fatalf("expected group-id, got %s", group.ID)
@@ -150,34 +150,34 @@ func TestRead(t *testing.T) {
150150
}
151151

152152
func TestUpdate(t *testing.T) {
153-
messagebirdtest.WillReturn([]byte(""), http.StatusNoContent)
154-
client := messagebirdtest.Client(t)
153+
mbtest.WillReturn([]byte(""), http.StatusNoContent)
154+
client := mbtest.Client(t)
155155

156156
if err := Update(client, "group-id", &Request{"Family"}); err != nil {
157157
t.Fatalf("unexpected error updating Group: %s", err)
158158
}
159159

160-
messagebirdtest.AssertEndpointCalled(t, http.MethodPatch, "/groups/group-id")
161-
messagebirdtest.AssertTestdata(t, "groupRequestUpdateObject.json", messagebirdtest.Request.Body)
160+
mbtest.AssertEndpointCalled(t, http.MethodPatch, "/groups/group-id")
161+
mbtest.AssertTestdata(t, "groupRequestUpdateObject.json", messagebirdtest.Request.Body)
162162
}
163163

164164
func TestAddContacts(t *testing.T) {
165-
messagebirdtest.WillReturn([]byte(""), http.StatusNoContent)
166-
client := messagebirdtest.Client(t)
165+
mbtest.WillReturn([]byte(""), http.StatusNoContent)
166+
client := mbtest.Client(t)
167167

168168
if err := AddContacts(client, "group-id", []string{"first-contact-id", "second-contact-id"}); err != nil {
169169
t.Fatalf("unexpected error removing Contacts from Group: %s", err)
170170
}
171171

172-
messagebirdtest.AssertEndpointCalled(t, http.MethodGet, "/groups/group-id/contacts")
172+
mbtest.AssertEndpointCalled(t, http.MethodGet, "/groups/group-id/contacts")
173173

174-
if messagebirdtest.Request.URL.RawQuery != "_method=PUT&ids[]=first-contact-id&ids[]=second-contact-id" {
174+
if mbtest.Request.URL.RawQuery != "_method=PUT&ids[]=first-contact-id&ids[]=second-contact-id" {
175175
t.Fatalf("expected _method=PUT&ids[]=first-contact-id&ids[]=second-contact-id, got %s", messagebirdtest.Request.URL.RawQuery)
176176
}
177177
}
178178

179179
func TestAddContactsWithEmptyContacts(t *testing.T) {
180-
client := messagebirdtest.Client(t)
180+
client := mbtest.Client(t)
181181

182182
tt := []struct {
183183
contactIDS []string
@@ -194,7 +194,7 @@ func TestAddContactsWithEmptyContacts(t *testing.T) {
194194
}
195195

196196
func TestAddContactsWithTooManyContacts(t *testing.T) {
197-
client := messagebirdtest.Client(t)
197+
client := mbtest.Client(t)
198198

199199
contactIDS := make([]string, 51)
200200

@@ -204,8 +204,8 @@ func TestAddContactsWithTooManyContacts(t *testing.T) {
204204
}
205205

206206
func TestListContacts(t *testing.T) {
207-
messagebirdtest.WillReturnTestdata(t, "groupContactListObject.json", http.StatusOK)
208-
client := messagebirdtest.Client(t)
207+
mbtest.WillReturnTestdata(t, "groupContactListObject.json", http.StatusOK)
208+
client := mbtest.Client(t)
209209

210210
list, err := ListContacts(client, "group-id", DefaultListOptions)
211211
if err != nil {
@@ -242,16 +242,16 @@ func TestListContacts(t *testing.T) {
242242

243243
client.DebugLog.Printf("list:\n%#v\n", list)
244244

245-
messagebirdtest.AssertEndpointCalled(t, http.MethodGet, "/groups/group-id/contacts")
245+
mbtest.AssertEndpointCalled(t, http.MethodGet, "/groups/group-id/contacts")
246246
}
247247

248248
func TestRemoveContact(t *testing.T) {
249-
messagebirdtest.WillReturn([]byte(""), http.StatusNoContent)
250-
client := messagebirdtest.Client(t)
249+
mbtest.WillReturn([]byte(""), http.StatusNoContent)
250+
client := mbtest.Client(t)
251251

252252
if err := RemoveContact(client, "group-id", "contact-id"); err != nil {
253253
t.Fatalf("unexpected error deleting Group: %s", err)
254254
}
255255

256-
messagebirdtest.AssertEndpointCalled(t, http.MethodDelete, "/groups/group-id/contacts/contact-id")
256+
mbtest.AssertEndpointCalled(t, http.MethodDelete, "/groups/group-id/contacts/contact-id")
257257
}

0 commit comments

Comments
 (0)