mock icon indicating copy to clipboard operation
mock copied to clipboard

Return last call for InOrder

Open codyoss opened this issue 5 years ago • 2 comments

The following changes InOrder to return the last called Call. This allows a more fluent design when using InOrder, things can be better chained together and allows composing of numerous InOrder calls.

Example:

func doX(ctrl *gomock.Controller) *gomock.Call {
    mock := NewMockA(ctrl)
    return gomock.InOrder(
        doZ(mock),
        mock.EXPECT().Foo().Return("bar"),
    )
}

func doY(ctrl *gomock.Controller) *gomock.Call {
    mock := NewMockB(ctrl)
    return gomock.InOrder(
        doZ(mock),
        mock.EXPECT().Bar().Return("foo"),
    )
}

gomock.InOrder(
    doX(ctrl),
    doY(ctrl),
)

Body here copied from #199

codyoss avatar Feb 22 '20 18:02 codyoss

This seems like a reasonable change, but it is breaking so holding off for now.

codyoss avatar Mar 06 '20 21:03 codyoss

it is breaking

Is it? Won't compile?

Because it is pure feat if it compiles.

UPD Some can make use of given func (...gomock.Call) signature indeed. Won't compile in this case. Pure feat though for a reasonable usage.

sirkon avatar Feb 25 '21 08:02 sirkon