Skip to content

Commit f08499c

Browse files
committed
fix typo except -> expect
1 parent 406337b commit f08499c

File tree

9 files changed

+111
-111
lines changed

9 files changed

+111
-111
lines changed

err2_test.go

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"testing"
1010

1111
"github.com/lainio/err2"
12-
"github.com/lainio/err2/internal/except"
12+
"github.com/lainio/err2/internal/expect"
1313
"github.com/lainio/err2/try"
1414
)
1515

@@ -70,7 +70,7 @@ func TestHandle_noerrHandler(t *testing.T) {
7070
var err error
7171
var handlerCalled bool
7272
defer func() {
73-
except.That(t, handlerCalled)
73+
expect.That(t, handlerCalled)
7474
}()
7575
// This is the handler we are testing!
7676
defer err2.Handle(&err, func(noerr bool) {
@@ -88,12 +88,12 @@ func TestHandle_noerrHandler(t *testing.T) {
8888
var err error
8989
var handlerCalled bool
9090
defer func() {
91-
except.That(t, handlerCalled)
91+
expect.That(t, handlerCalled)
9292
}()
9393
defer err2.Handle(&err, func(err error) error {
9494
// this should not be called, so lets try to fuckup things...
9595
handlerCalled = false
96-
except.That(t, false)
96+
expect.That(t, false)
9797
return err
9898
})
9999

@@ -111,20 +111,20 @@ func TestHandle_noerrHandler(t *testing.T) {
111111
var err error
112112
var handlerCalled bool
113113
defer func() {
114-
except.ThatNot(t, handlerCalled)
114+
expect.ThatNot(t, handlerCalled)
115115
}()
116116

117117
// This is the handler we are testing!
118118
defer err2.Handle(&err, func(err error) error {
119-
except.ThatNot(t, handlerCalled)
119+
expect.ThatNot(t, handlerCalled)
120120
handlerCalled = false
121-
except.That(t, true, "error should be handled")
121+
expect.That(t, true, "error should be handled")
122122
return err
123123
})
124124

125125
// This is the handler we are testing! AND it's not called in error.
126126
defer err2.Handle(&err, func(bool) {
127-
except.That(t, false, "when error this is not called")
127+
expect.That(t, false, "when error this is not called")
128128
})
129129

130130
try.To1(throw())
@@ -141,14 +141,14 @@ func TestHandle_noerrHandler(t *testing.T) {
141141
callCount int
142142
)
143143
defer func() {
144-
except.ThatNot(t, handlerCalled)
145-
except.Equal(t, callCount, 2)
146-
except.Equal(t, err.Error(), finalAnnotatedErr.Error())
144+
expect.ThatNot(t, handlerCalled)
145+
expect.Equal(t, callCount, 2)
146+
expect.Equal(t, err.Error(), finalAnnotatedErr.Error())
147147
}()
148148

149149
// This is the handler we are testing! AND it's not called in error.
150150
defer err2.Handle(&err, func(noerr bool) {
151-
except.That(
151+
expect.That(
152152
t,
153153
false,
154154
"if error occurs/reset, this cannot happen",
@@ -159,18 +159,18 @@ func TestHandle_noerrHandler(t *testing.T) {
159159
// important! test that our handler doesn't change the current error
160160
// and it's not nil
161161
defer err2.Handle(&err, func(er error) error {
162-
except.That(t, er != nil, "er val: ", er, err)
163-
except.Equal(t, callCount, 1, "this is called in sencond")
162+
expect.That(t, er != nil, "er val: ", er, err)
163+
expect.Equal(t, callCount, 1, "this is called in sencond")
164164
callCount++
165165
return er
166166
})
167167

168168
defer err2.Handle(&err, func(err error) error {
169169
// this should not be called, so lets try to fuckup things...
170-
except.Equal(t, callCount, 0, "this is called in first")
170+
expect.Equal(t, callCount, 0, "this is called in first")
171171
callCount++
172172
handlerCalled = false
173-
except.That(t, err != nil)
173+
expect.That(t, err != nil)
174174
return finalAnnotatedErr
175175
})
176176
try.To1(throw())
@@ -182,17 +182,17 @@ func TestHandle_noerrHandler(t *testing.T) {
182182
var err error
183183
var handlerCalled bool
184184
defer func() {
185-
except.That(t, handlerCalled)
185+
expect.That(t, handlerCalled)
186186
}()
187187

188188
// This is the handler we are testing!
189189
defer err2.Handle(&err, func(noerr bool) {
190-
except.That(t, noerr)
190+
expect.That(t, noerr)
191191
handlerCalled = noerr
192192
})
193193

194194
defer err2.Handle(&err, func(err error) error {
195-
except.That(t, false, "no error to handle!")
195+
expect.That(t, false, "no error to handle!")
196196
// this should not be called, so lets try to fuckup things...
197197
handlerCalled = false // see first deferred function
198198
return err
@@ -207,27 +207,27 @@ func TestHandle_noerrHandler(t *testing.T) {
207207
var err error
208208
var handlerCalled bool
209209
defer func() {
210-
except.That(t, handlerCalled)
210+
expect.That(t, handlerCalled)
211211
}()
212212

213213
// This is the handler we are testing!
214214
defer err2.Handle(&err, func(noerr bool) {
215-
except.That(t, true)
216-
except.That(t, noerr)
215+
expect.That(t, true)
216+
expect.That(t, noerr)
217217
handlerCalled = noerr
218218
})
219219

220220
defer err2.Handle(&err)
221221

222222
defer err2.Handle(&err, func(err error) error {
223-
except.That(t, false, "no error to handle!")
223+
expect.That(t, false, "no error to handle!")
224224
// this should not be called, so lets try to fuckup things...
225225
handlerCalled = false // see first deferred function
226226
return err
227227
})
228228

229229
defer err2.Handle(&err, func(err error) error {
230-
except.That(t, false, "no error to handle!")
230+
expect.That(t, false, "no error to handle!")
231231
// this should not be called, so lets try to fuckup things...
232232
handlerCalled = false // see first deferred function
233233
return err
@@ -243,20 +243,20 @@ func TestHandle_noerrHandler(t *testing.T) {
243243
var err error
244244
var noerrHandlerCalled, errHandlerCalled bool
245245
defer func() {
246-
except.That(t, noerrHandlerCalled)
247-
except.That(t, errHandlerCalled)
246+
expect.That(t, noerrHandlerCalled)
247+
expect.That(t, errHandlerCalled)
248248
}()
249249

250250
// This is the handler we are testing!
251251
defer err2.Handle(&err, func(noerr bool) {
252-
except.That(t, true) // we are here, for debugging
253-
except.That(t, noerr)
252+
expect.That(t, true) // we are here, for debugging
253+
expect.That(t, noerr)
254254
noerrHandlerCalled = noerr
255255
})
256256

257257
// this is the err handler that -- RESETS -- the error to nil
258258
defer err2.Handle(&err, func(err error) error {
259-
except.That(t, err != nil) // helps fast debugging
259+
expect.That(t, err != nil) // helps fast debugging
260260

261261
// this should not be called, so lets try to fuckup things...
262262
noerrHandlerCalled = false // see first deferred function
@@ -266,7 +266,7 @@ func TestHandle_noerrHandler(t *testing.T) {
266266
})
267267

268268
defer err2.Handle(&err, func(err error) error {
269-
except.That(t, err != nil) // helps fast debugging
269+
expect.That(t, err != nil) // helps fast debugging
270270
// this should not be called, so lets try to fuckup things...
271271
noerrHandlerCalled = false // see first deferred function
272272

@@ -284,28 +284,28 @@ func TestHandle_noerrHandler(t *testing.T) {
284284
var err error
285285
var handlerCalled bool
286286
defer func() {
287-
except.That(t, handlerCalled)
287+
expect.That(t, handlerCalled)
288288
}()
289289

290290
defer err2.Handle(&err)
291291
defer err2.Handle(&err)
292292

293293
defer err2.Handle(&err, func(err error) error {
294-
except.That(t, false, "no error to handle!")
294+
expect.That(t, false, "no error to handle!")
295295
// this should not be called, so lets try to fuckup things...
296296
handlerCalled = false // see first deferred function
297297
return err
298298
})
299299

300300
// This is the handler we are testing!
301301
defer err2.Handle(&err, func(noerr bool) {
302-
except.That(t, true, "this must be called")
303-
except.That(t, noerr)
302+
expect.That(t, true, "this must be called")
303+
expect.That(t, noerr)
304304
handlerCalled = noerr
305305
})
306306

307307
defer err2.Handle(&err, func(err error) error {
308-
except.That(t, false, "no error to handle!")
308+
expect.That(t, false, "no error to handle!")
309309
// this should not be called, so lets try to fuckup things...
310310
handlerCalled = false // see first deferred function
311311
return err
@@ -376,7 +376,7 @@ func TestPanickingCatchAll(t *testing.T) {
376376
t.Run(tt.name, func(t *testing.T) {
377377
t.Parallel()
378378
defer func() {
379-
except.That(
379+
expect.That(
380380
t,
381381
recover() == nil,
382382
"panics should NOT carry on",
@@ -424,7 +424,7 @@ func TestPanickingCarryOn_Handle(t *testing.T) {
424424
t.Run(tt.name, func(t *testing.T) {
425425
t.Parallel()
426426
defer func() {
427-
except.That(
427+
expect.That(
428428
t,
429429
recover() != nil,
430430
"panics should went thru when not our errors",
@@ -554,12 +554,12 @@ func TestPanicking_Handle(t *testing.T) {
554554
defer func() {
555555
r := recover()
556556
if tt.wants == nil {
557-
except.That(t, r != nil, "wants err, then panic")
557+
expect.That(t, r != nil, "wants err, then panic")
558558
}
559559
}()
560560
err := tt.args.f()
561561
if err != nil {
562-
except.Equal(t, err.Error(), tt.wants.Error())
562+
expect.Equal(t, err.Error(), tt.wants.Error())
563563
}
564564
})
565565
}
@@ -600,7 +600,7 @@ func TestPanicking_Catch(t *testing.T) {
600600
t.Run(tt.name, func(t *testing.T) {
601601
t.Parallel()
602602
defer func() {
603-
except.That(
603+
expect.That(
604604
t,
605605
recover() == nil,
606606
"panics should NOT carry on",
@@ -623,7 +623,7 @@ func TestCatch_Error(t *testing.T) {
623623
func Test_TryOutError(t *testing.T) {
624624
t.Parallel()
625625
defer err2.Catch(func(err error) error {
626-
except.Equal(t, err.Error(), "fails: test: this is an ERROR",
626+
expect.Equal(t, err.Error(), "fails: test: this is an ERROR",
627627
"=> we should catch right error str here")
628628
return err
629629
})
@@ -633,7 +633,7 @@ func Test_TryOutError(t *testing.T) {
633633
// let's test try.Out1() and it's throw capabilities here, even try.To1()
634634
// is the preferred way.
635635
retVal = try.Out1(noThrow()).Handle().Val1
636-
except.Equal(t, retVal, "test", "if no error happens, we get value")
636+
expect.Equal(t, retVal, "test", "if no error happens, we get value")
637637

638638
_ = try.Out1(throw()).Handle("fails: %v", retVal).Val1
639639
t.Fail() // If everything works in Handle we are never here.
@@ -665,21 +665,21 @@ func TestCatch_Panic(t *testing.T) {
665665
func TestSetErrorTracer(t *testing.T) {
666666
t.Parallel()
667667
w := err2.ErrorTracer()
668-
except.That(t, w == nil, "error tracer should be nil")
668+
expect.That(t, w == nil, "error tracer should be nil")
669669
var w1 io.Writer
670670
err2.SetErrorTracer(w1)
671671
w = err2.ErrorTracer()
672-
except.That(t, w == nil, "error tracer should be nil")
672+
expect.That(t, w == nil, "error tracer should be nil")
673673
}
674674

675675
func TestSetErrRetTracer(t *testing.T) {
676676
t.Parallel()
677677
w := err2.ErrRetTracer()
678-
except.That(t, w == nil, "error return tracer should be nil")
678+
expect.That(t, w == nil, "error return tracer should be nil")
679679
var w1 io.Writer
680680
err2.SetErrRetTracer(w1)
681681
w = err2.ErrRetTracer()
682-
except.That(t, w == nil, "error return tracer should be nil")
682+
expect.That(t, w == nil, "error return tracer should be nil")
683683
}
684684

685685
func ExampleCatch_withFmt() {

0 commit comments

Comments
 (0)