(t *testing.T)
| 360 | } |
| 361 | |
| 362 | func Test_Mock_On_WithFuncArgMatcher(t *testing.T) { |
| 363 | t.Parallel() |
| 364 | |
| 365 | var mockedService TestExampleImplementation |
| 366 | |
| 367 | fixture1, fixture2 := errors.New("fixture1"), errors.New("fixture2") |
| 368 | |
| 369 | mockedService.On("TheExampleMethodFunc", |
| 370 | MatchedBy(func(a func(string) error) bool { return a != nil && a("string") == fixture1 }), |
| 371 | ).Return(errors.New("fixture1")) |
| 372 | |
| 373 | mockedService.On("TheExampleMethodFunc", |
| 374 | MatchedBy(func(a func(string) error) bool { return a != nil && a("string") == fixture2 }), |
| 375 | ).Return(errors.New("fixture2")) |
| 376 | |
| 377 | mockedService.On("TheExampleMethodFunc", |
| 378 | MatchedBy(func(a func(string) error) bool { return a == nil }), |
| 379 | ).Return(errors.New("fixture3")) |
| 380 | |
| 381 | assert.EqualError(t, mockedService.TheExampleMethodFunc( |
| 382 | func(string) error { return fixture1 }), "fixture1") |
| 383 | assert.EqualError(t, mockedService.TheExampleMethodFunc( |
| 384 | func(string) error { return fixture2 }), "fixture2") |
| 385 | assert.EqualError(t, mockedService.TheExampleMethodFunc(nil), "fixture3") |
| 386 | } |
| 387 | |
| 388 | func Test_Mock_On_WithInterfaceArgMatcher(t *testing.T) { |
| 389 | t.Parallel() |
nothing calls this directly
no test coverage detected
searching dependent graphs…