Skip to content

Commit 2d778ee

Browse files
committed
style: code cleanup
1 parent 7012f4e commit 2d778ee

2 files changed

Lines changed: 13 additions & 13 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ func TestBot_Ping(t *testing.T) {
7676

7777
#### Advanced Testing
7878

79-
Now imagine a bit more complicated command, that has variable messages and uses sub tests instead of a single test:
79+
Now imagine a bit more complicated test, that has multiple sub-tests:
8080

8181
```go
8282
func (b *Bot) Ping(e *gateway.MessageCreateEvent) (error) {
@@ -93,7 +93,7 @@ func (b *Bot) Ping(e *gateway.MessageCreateEvent) (error) {
9393

9494
```go
9595
func TestBot_Ping(t *testing.T) {
96-
m, s := dismock.NewState(t)
96+
m := dismock.New(t)
9797

9898
var channelID discord.Snowflake = 123
9999

pkg/dismock/mocker_test.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ func TestMocker_Server(t *testing.T) {
100100

101101
t.Run("delete", func(t *testing.T) {
102102
t.Run("only handler and only method", func(t *testing.T) {
103-
m, _ := NewSession(t)
103+
m := New(t)
104104

105105
m.handlers["/path"] = make(map[string][]Handler)
106106

@@ -123,7 +123,7 @@ func TestMocker_Server(t *testing.T) {
123123
})
124124

125125
t.Run("only handler multiple methods", func(t *testing.T) {
126-
m, _ := NewSession(t)
126+
m := New(t)
127127

128128
m.handlers["/path"] = make(map[string][]Handler)
129129

@@ -151,7 +151,7 @@ func TestMocker_Server(t *testing.T) {
151151
})
152152

153153
t.Run("multiple handlers", func(t *testing.T) {
154-
m, _ := NewSession(t)
154+
m := New(t)
155155

156156
m.handlers["/path"] = make(map[string][]Handler)
157157

@@ -179,7 +179,7 @@ func TestMocker_Server(t *testing.T) {
179179

180180
func TestMocker_Mock(t *testing.T) {
181181
t.Run("success", func(t *testing.T) {
182-
m, _ := NewSession(t)
182+
m := New(t)
183183

184184
invoked := false
185185

@@ -199,7 +199,7 @@ func TestMocker_Mock(t *testing.T) {
199199
})
200200

201201
t.Run("nil support", func(t *testing.T) {
202-
m, _ := NewSession(t)
202+
m := New(t)
203203

204204
method := http.MethodPost
205205
path := "/path/123"
@@ -237,7 +237,7 @@ func TestMocker_Clone(t *testing.T) {
237237
}
238238

239239
func TestMocker_CloneSession(t *testing.T) {
240-
m1, _ := NewSession(new(testing.T))
240+
m1 := New(new(testing.T))
241241

242242
m1.handlers["path"] = map[string][]Handler{
243243
http.MethodGet: {},
@@ -256,7 +256,7 @@ func TestMocker_CloneSession(t *testing.T) {
256256
}
257257

258258
func TestMocker_CloneState(t *testing.T) {
259-
m1, _ := NewState(new(testing.T))
259+
m1 := New(new(testing.T))
260260

261261
m1.handlers["path"] = map[string][]Handler{
262262
http.MethodGet: {},
@@ -296,7 +296,7 @@ func TestMocker_Eval(t *testing.T) {
296296
t.Run("success", func(t *testing.T) {
297297
tMock := new(testing.T)
298298

299-
m, _ := NewSession(tMock)
299+
m := New(tMock)
300300

301301
m.Eval()
302302

@@ -307,7 +307,7 @@ func TestMocker_Eval(t *testing.T) {
307307
t.Run("failure", func(t *testing.T) {
308308
tMock := new(testing.T)
309309

310-
m, _ := NewSession(tMock)
310+
m := New(tMock)
311311

312312
m.handlers["path"] = map[string][]Handler{
313313
"request0": {},
@@ -328,7 +328,7 @@ func TestMocker_Eval(t *testing.T) {
328328

329329
func TestMocker_genUninvokedMsg(t *testing.T) {
330330
t.Run("singular", func(t *testing.T) {
331-
m, _ := NewSession(new(testing.T))
331+
m := New(new(testing.T))
332332

333333
expect := "path:\n\trequest0: 1 uninvoked handler"
334334

@@ -345,7 +345,7 @@ func TestMocker_genUninvokedMsg(t *testing.T) {
345345
})
346346

347347
t.Run("plural", func(t *testing.T) {
348-
m, _ := NewSession(new(testing.T))
348+
m := New(new(testing.T))
349349

350350
expect := "path:\n\trequest0: 2 uninvoked handlers"
351351

0 commit comments

Comments
 (0)