File tree 1 file changed +10
-11
lines changed
1 file changed +10
-11
lines changed Original file line number Diff line number Diff line change @@ -179,6 +179,14 @@ const (
179
179
// PushTester allows you to change the current default asserter by accepting it
180
180
// as a second argument.
181
181
//
182
+ // Note that you MUST call PushTester for sub-goroutines:
183
+ //
184
+ // defer assert.PushTester(t)() // does the cleanup
185
+ // ...
186
+ // go func() {
187
+ // assert.PushTester(t) // left cleanup out! Leave it for the test, see ^
188
+ // ...
189
+ //
182
190
// Note that the second argument, if given, changes the default asserter for
183
191
// whole package. The argument is mainly for temporary development use and isn't
184
192
// not preferred API usage.
@@ -190,13 +198,7 @@ func PushTester(t testing.TB, a ...defInd) function {
190
198
// it's good to keep the API as simple as possible
191
199
SetDefault (TestFull )
192
200
}
193
- testers .Tx (func (m testersMap ) {
194
- rid := goid ()
195
- if _ , ok := m [rid ]; ok {
196
- panic ("PushTester is already called" )
197
- }
198
- m [rid ] = t
199
- })
201
+ testers .Set (goid (), t )
200
202
return PopTester
201
203
}
202
204
@@ -219,10 +221,7 @@ func PushTester(t testing.TB, a ...defInd) function {
219
221
//
220
222
// defer assert.PushTester(t)()
221
223
func PopTester () {
222
- defer testers .Tx (func (m testersMap ) {
223
- goid := goid ()
224
- delete (m , goid )
225
- })
224
+ defer testers .Del (goid ())
226
225
227
226
r := recover ()
228
227
if r == nil {
You can’t perform that action at this time.
0 commit comments