1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
package mock_rpc
import (
"io"
"gitlab.com/gitlab-org/cluster-integration/gitlab-agent/v16/internal/tool/testing/testhelpers"
"go.uber.org/mock/gomock"
"google.golang.org/protobuf/proto"
)
func InitMockClientStream(ctrl *gomock.Controller, eof bool, msgs ...proto.Message) (*MockClientStream, []any) {
stream := NewMockClientStream(ctrl)
res := make([]any, 0, len(msgs)+1)
for _, msg := range msgs {
call := stream.EXPECT().
RecvMsg(gomock.Any()).
Do(testhelpers.RecvMsg(msg))
res = append(res, call)
}
if eof {
call := stream.EXPECT().
RecvMsg(gomock.Any()).
Return(io.EOF)
res = append(res, call)
}
return stream, res
}
|