MCPcopy
hub / github.com/stretchr/testify / Test_Mock_On_WithArgMatcherThatPanics

Function Test_Mock_On_WithArgMatcherThatPanics

mock/mock_test.go:282–308  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

280}
281
282func Test_Mock_On_WithArgMatcherThatPanics(t *testing.T) {
283 t.Parallel()
284
285 var mockedService TestExampleImplementation
286
287 mockedService.On("TheExampleMethod2", MatchedBy(func(_ interface{}) bool {
288 panic("try to lock mockedService")
289 })).Return()
290
291 defer func() {
292 assertedExpectations := make(chan struct{})
293 go func() {
294 tt := new(testing.T)
295 mockedService.AssertExpectations(tt)
296 close(assertedExpectations)
297 }()
298 select {
299 case <-assertedExpectations:
300 case <-time.After(time.Second):
301 t.Fatal("AssertExpectations() deadlocked, did the panic leave mockedService locked?")
302 }
303 }()
304
305 assert.Panics(t, func() {
306 mockedService.TheExampleMethod2(false)
307 })
308}
309
310func TestMock_WithTest(t *testing.T) {
311 t.Parallel()

Callers

nothing calls this directly

Calls 7

TheExampleMethod2Method · 0.95
PanicsFunction · 0.92
MatchedByFunction · 0.85
ReturnMethod · 0.80
AfterMethod · 0.80
AssertExpectationsMethod · 0.65
OnMethod · 0.45

Tested by

no test coverage detected