| 668 | } |
| 669 | |
| 670 | func Test_Mock_UnsetByOnMethodSpecAmongOthers(t *testing.T) { |
| 671 | t.Parallel() |
| 672 | |
| 673 | // make a test impl object |
| 674 | var mockedService = new(TestExampleImplementation) |
| 675 | |
| 676 | _, filename, line, _ := runtime.Caller(0) |
| 677 | mock1 := mockedService. |
| 678 | On("TheExampleMethod", 1, 2, 3). |
| 679 | Return(0, nil). |
| 680 | On("TheExampleMethodVariadic", 1, 2, 3, 4, 5).Once(). |
| 681 | Return(nil) |
| 682 | mock1. |
| 683 | On("TheExampleMethodFuncType", Anything). |
| 684 | Return(nil) |
| 685 | |
| 686 | assert.Equal(t, 3, len(mockedService.ExpectedCalls)) |
| 687 | mock1.On("TheExampleMethod", 1, 2, 3). |
| 688 | Return(0, nil).Unset() |
| 689 | |
| 690 | assert.Equal(t, 2, len(mockedService.ExpectedCalls)) |
| 691 | |
| 692 | expectedCalls := []*Call{ |
| 693 | { |
| 694 | Parent: &mockedService.Mock, |
| 695 | Method: "TheExampleMethodVariadic", |
| 696 | Repeatability: 1, |
| 697 | Arguments: []interface{}{1, 2, 3, 4, 5}, |
| 698 | ReturnArguments: []interface{}{nil}, |
| 699 | callerInfo: []string{fmt.Sprintf("%s:%d", filename, line+4)}, |
| 700 | }, |
| 701 | { |
| 702 | Parent: &mockedService.Mock, |
| 703 | Method: "TheExampleMethodFuncType", |
| 704 | Arguments: []interface{}{Anything}, |
| 705 | ReturnArguments: []interface{}{nil}, |
| 706 | callerInfo: []string{fmt.Sprintf("%s:%d", filename, line+7)}, |
| 707 | }, |
| 708 | } |
| 709 | |
| 710 | assert.Equal(t, 2, len(mockedService.ExpectedCalls)) |
| 711 | assert.Equal(t, expectedCalls, mockedService.ExpectedCalls) |
| 712 | } |
| 713 | |
| 714 | func Test_Mock_Unset_WithFuncPanics(t *testing.T) { |
| 715 | t.Parallel() |