From efe6d02bef112634eaf77ed6c41ba9f3cf9bbb74 Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Sat, 20 Feb 2021 09:46:41 +0800 Subject: [PATCH] use mockgen source mode --- .../mock_sent_packet_tracker_test.go | 2 +- .../handshake/mock_handshake_runner_test.go | 2 +- mock_ack_frame_source_test.go | 10 ++-- mock_crypto_data_handler_test.go | 2 +- mock_crypto_stream_test.go | 10 ++-- mock_frame_source_test.go | 2 +- mock_multiplexer_test.go | 10 ++-- mock_packer_test.go | 10 ++-- mock_packet_handler_manager_test.go | 2 +- mock_packet_handler_test.go | 2 +- mock_quic_session_test.go | 4 +- mock_receive_stream_internal_test.go | 24 ++++---- mock_sealing_manager_test.go | 2 +- mock_send_conn_test.go | 2 +- mock_send_stream_internal_test.go | 32 +++++----- mock_sender_test.go | 10 ++-- mock_session_runner_test.go | 2 +- mock_stream_getter_test.go | 2 +- mock_stream_internal_test.go | 58 +++++++++---------- mock_stream_manager_test.go | 2 +- mock_stream_sender_test.go | 2 +- mock_unknown_packet_handler_test.go | 2 +- mock_unpacker_test.go | 10 ++-- mockgen_private.sh | 53 ++++++++++++++--- 24 files changed, 146 insertions(+), 111 deletions(-) diff --git a/internal/ackhandler/mock_sent_packet_tracker_test.go b/internal/ackhandler/mock_sent_packet_tracker_test.go index 2490c40b..647fbc89 100644 --- a/internal/ackhandler/mock_sent_packet_tracker_test.go +++ b/internal/ackhandler/mock_sent_packet_tracker_test.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/lucas-clemente/quic-go/internal/ackhandler (interfaces: SentPacketTracker) +// Source: interfaces.go // Package ackhandler is a generated GoMock package. package ackhandler diff --git a/internal/handshake/mock_handshake_runner_test.go b/internal/handshake/mock_handshake_runner_test.go index 574cabe3..d59e0762 100644 --- a/internal/handshake/mock_handshake_runner_test.go +++ b/internal/handshake/mock_handshake_runner_test.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/lucas-clemente/quic-go/internal/handshake (interfaces: HandshakeRunner) +// Source: interface.go // Package handshake is a generated GoMock package. package handshake diff --git a/mock_ack_frame_source_test.go b/mock_ack_frame_source_test.go index c8439c09..22fd107a 100644 --- a/mock_ack_frame_source_test.go +++ b/mock_ack_frame_source_test.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/lucas-clemente/quic-go (interfaces: AckFrameSource) +// Source: packet_packer.go // Package quic is a generated GoMock package. package quic @@ -36,15 +36,15 @@ func (m *MockAckFrameSource) EXPECT() *MockAckFrameSourceMockRecorder { } // GetAckFrame mocks base method. -func (m *MockAckFrameSource) GetAckFrame(arg0 protocol.EncryptionLevel, arg1 bool) *wire.AckFrame { +func (m *MockAckFrameSource) GetAckFrame(encLevel protocol.EncryptionLevel, onlyIfQueued bool) *wire.AckFrame { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetAckFrame", arg0, arg1) + ret := m.ctrl.Call(m, "GetAckFrame", encLevel, onlyIfQueued) ret0, _ := ret[0].(*wire.AckFrame) return ret0 } // GetAckFrame indicates an expected call of GetAckFrame. -func (mr *MockAckFrameSourceMockRecorder) GetAckFrame(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockAckFrameSourceMockRecorder) GetAckFrame(encLevel, onlyIfQueued interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAckFrame", reflect.TypeOf((*MockAckFrameSource)(nil).GetAckFrame), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAckFrame", reflect.TypeOf((*MockAckFrameSource)(nil).GetAckFrame), encLevel, onlyIfQueued) } diff --git a/mock_crypto_data_handler_test.go b/mock_crypto_data_handler_test.go index c7c18ada..11a99e70 100644 --- a/mock_crypto_data_handler_test.go +++ b/mock_crypto_data_handler_test.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/lucas-clemente/quic-go (interfaces: CryptoDataHandler) +// Source: crypto_stream_manager.go // Package quic is a generated GoMock package. package quic diff --git a/mock_crypto_stream_test.go b/mock_crypto_stream_test.go index be271112..ccc04d44 100644 --- a/mock_crypto_stream_test.go +++ b/mock_crypto_stream_test.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/lucas-clemente/quic-go (interfaces: CryptoStream) +// Source: crypto_stream.go // Package quic is a generated GoMock package. package quic @@ -106,16 +106,16 @@ func (mr *MockCryptoStreamMockRecorder) PopCryptoFrame(arg0 interface{}) *gomock } // Write mocks base method. -func (m *MockCryptoStream) Write(arg0 []byte) (int, error) { +func (m *MockCryptoStream) Write(p []byte) (int, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Write", arg0) + ret := m.ctrl.Call(m, "Write", p) ret0, _ := ret[0].(int) ret1, _ := ret[1].(error) return ret0, ret1 } // Write indicates an expected call of Write. -func (mr *MockCryptoStreamMockRecorder) Write(arg0 interface{}) *gomock.Call { +func (mr *MockCryptoStreamMockRecorder) Write(p interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Write", reflect.TypeOf((*MockCryptoStream)(nil).Write), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Write", reflect.TypeOf((*MockCryptoStream)(nil).Write), p) } diff --git a/mock_frame_source_test.go b/mock_frame_source_test.go index 4d13093f..616af4c1 100644 --- a/mock_frame_source_test.go +++ b/mock_frame_source_test.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/lucas-clemente/quic-go (interfaces: FrameSource) +// Source: packet_packer.go // Package quic is a generated GoMock package. package quic diff --git a/mock_multiplexer_test.go b/mock_multiplexer_test.go index 7909b288..ccc750c1 100644 --- a/mock_multiplexer_test.go +++ b/mock_multiplexer_test.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/lucas-clemente/quic-go (interfaces: Multiplexer) +// Source: multiplexer.go // Package quic is a generated GoMock package. package quic @@ -36,18 +36,18 @@ func (m *MockMultiplexer) EXPECT() *MockMultiplexerMockRecorder { } // AddConn mocks base method. -func (m *MockMultiplexer) AddConn(arg0 net.PacketConn, arg1 int, arg2 []byte, arg3 logging.Tracer) (packetHandlerManager, error) { +func (m *MockMultiplexer) AddConn(c net.PacketConn, connIDLen int, statelessResetKey []byte, tracer logging.Tracer) (packetHandlerManager, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "AddConn", arg0, arg1, arg2, arg3) + ret := m.ctrl.Call(m, "AddConn", c, connIDLen, statelessResetKey, tracer) ret0, _ := ret[0].(packetHandlerManager) ret1, _ := ret[1].(error) return ret0, ret1 } // AddConn indicates an expected call of AddConn. -func (mr *MockMultiplexerMockRecorder) AddConn(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { +func (mr *MockMultiplexerMockRecorder) AddConn(c, connIDLen, statelessResetKey, tracer interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddConn", reflect.TypeOf((*MockMultiplexer)(nil).AddConn), arg0, arg1, arg2, arg3) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddConn", reflect.TypeOf((*MockMultiplexer)(nil).AddConn), c, connIDLen, statelessResetKey, tracer) } // RemoveConn mocks base method. diff --git a/mock_packer_test.go b/mock_packer_test.go index cf6fef50..fc633e97 100644 --- a/mock_packer_test.go +++ b/mock_packer_test.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/lucas-clemente/quic-go (interfaces: Packer) +// Source: packet_packer.go // Package quic is a generated GoMock package. package quic @@ -49,18 +49,18 @@ func (mr *MockPackerMockRecorder) HandleTransportParameters(arg0 interface{}) *g } // MaybePackAckPacket mocks base method. -func (m *MockPacker) MaybePackAckPacket(arg0 bool) (*packedPacket, error) { +func (m *MockPacker) MaybePackAckPacket(handshakeConfirmed bool) (*packedPacket, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "MaybePackAckPacket", arg0) + ret := m.ctrl.Call(m, "MaybePackAckPacket", handshakeConfirmed) ret0, _ := ret[0].(*packedPacket) ret1, _ := ret[1].(error) return ret0, ret1 } // MaybePackAckPacket indicates an expected call of MaybePackAckPacket. -func (mr *MockPackerMockRecorder) MaybePackAckPacket(arg0 interface{}) *gomock.Call { +func (mr *MockPackerMockRecorder) MaybePackAckPacket(handshakeConfirmed interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "MaybePackAckPacket", reflect.TypeOf((*MockPacker)(nil).MaybePackAckPacket), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "MaybePackAckPacket", reflect.TypeOf((*MockPacker)(nil).MaybePackAckPacket), handshakeConfirmed) } // MaybePackProbePacket mocks base method. diff --git a/mock_packet_handler_manager_test.go b/mock_packet_handler_manager_test.go index 45e72f3d..01553655 100644 --- a/mock_packet_handler_manager_test.go +++ b/mock_packet_handler_manager_test.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/lucas-clemente/quic-go (interfaces: PacketHandlerManager) +// Source: server.go // Package quic is a generated GoMock package. package quic diff --git a/mock_packet_handler_test.go b/mock_packet_handler_test.go index 143e7dd6..0516bcbe 100644 --- a/mock_packet_handler_test.go +++ b/mock_packet_handler_test.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/lucas-clemente/quic-go (interfaces: PacketHandler) +// Source: server.go // Package quic is a generated GoMock package. package quic diff --git a/mock_quic_session_test.go b/mock_quic_session_test.go index ae8ea245..b36a2627 100644 --- a/mock_quic_session_test.go +++ b/mock_quic_session_test.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/lucas-clemente/quic-go (interfaces: QuicSession) +// Source: server.go // Package quic is a generated GoMock package. package quic @@ -67,7 +67,7 @@ func (mr *MockQuicSessionMockRecorder) AcceptUniStream(arg0 interface{}) *gomock } // CloseWithError mocks base method. -func (m *MockQuicSession) CloseWithError(arg0 protocol.ApplicationErrorCode, arg1 string) error { +func (m *MockQuicSession) CloseWithError(arg0 ErrorCode, arg1 string) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "CloseWithError", arg0, arg1) ret0, _ := ret[0].(error) diff --git a/mock_receive_stream_internal_test.go b/mock_receive_stream_internal_test.go index d9380aaf..bdf02aaa 100644 --- a/mock_receive_stream_internal_test.go +++ b/mock_receive_stream_internal_test.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/lucas-clemente/quic-go (interfaces: ReceiveStreamI) +// Source: receive_stream.go // Package quic is a generated GoMock package. package quic @@ -37,7 +37,7 @@ func (m *MockReceiveStreamI) EXPECT() *MockReceiveStreamIMockRecorder { } // CancelRead mocks base method. -func (m *MockReceiveStreamI) CancelRead(arg0 protocol.ApplicationErrorCode) { +func (m *MockReceiveStreamI) CancelRead(arg0 ErrorCode) { m.ctrl.T.Helper() m.ctrl.Call(m, "CancelRead", arg0) } @@ -49,39 +49,39 @@ func (mr *MockReceiveStreamIMockRecorder) CancelRead(arg0 interface{}) *gomock.C } // Read mocks base method. -func (m *MockReceiveStreamI) Read(arg0 []byte) (int, error) { +func (m *MockReceiveStreamI) Read(p []byte) (int, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Read", arg0) + ret := m.ctrl.Call(m, "Read", p) ret0, _ := ret[0].(int) ret1, _ := ret[1].(error) return ret0, ret1 } // Read indicates an expected call of Read. -func (mr *MockReceiveStreamIMockRecorder) Read(arg0 interface{}) *gomock.Call { +func (mr *MockReceiveStreamIMockRecorder) Read(p interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Read", reflect.TypeOf((*MockReceiveStreamI)(nil).Read), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Read", reflect.TypeOf((*MockReceiveStreamI)(nil).Read), p) } // SetReadDeadline mocks base method. -func (m *MockReceiveStreamI) SetReadDeadline(arg0 time.Time) error { +func (m *MockReceiveStreamI) SetReadDeadline(t time.Time) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SetReadDeadline", arg0) + ret := m.ctrl.Call(m, "SetReadDeadline", t) ret0, _ := ret[0].(error) return ret0 } // SetReadDeadline indicates an expected call of SetReadDeadline. -func (mr *MockReceiveStreamIMockRecorder) SetReadDeadline(arg0 interface{}) *gomock.Call { +func (mr *MockReceiveStreamIMockRecorder) SetReadDeadline(t interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetReadDeadline", reflect.TypeOf((*MockReceiveStreamI)(nil).SetReadDeadline), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetReadDeadline", reflect.TypeOf((*MockReceiveStreamI)(nil).SetReadDeadline), t) } // StreamID mocks base method. -func (m *MockReceiveStreamI) StreamID() protocol.StreamID { +func (m *MockReceiveStreamI) StreamID() StreamID { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "StreamID") - ret0, _ := ret[0].(protocol.StreamID) + ret0, _ := ret[0].(StreamID) return ret0 } diff --git a/mock_sealing_manager_test.go b/mock_sealing_manager_test.go index 2cdb5e89..b0d332d9 100644 --- a/mock_sealing_manager_test.go +++ b/mock_sealing_manager_test.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/lucas-clemente/quic-go (interfaces: SealingManager) +// Source: packet_packer.go // Package quic is a generated GoMock package. package quic diff --git a/mock_send_conn_test.go b/mock_send_conn_test.go index ac0d8637..d66fec5f 100644 --- a/mock_send_conn_test.go +++ b/mock_send_conn_test.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/lucas-clemente/quic-go (interfaces: SendConn) +// Source: send_conn.go // Package quic is a generated GoMock package. package quic diff --git a/mock_send_stream_internal_test.go b/mock_send_stream_internal_test.go index 449e371e..d37a1bfd 100644 --- a/mock_send_stream_internal_test.go +++ b/mock_send_stream_internal_test.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/lucas-clemente/quic-go (interfaces: SendStreamI) +// Source: send_stream.go // Package quic is a generated GoMock package. package quic @@ -39,7 +39,7 @@ func (m *MockSendStreamI) EXPECT() *MockSendStreamIMockRecorder { } // CancelWrite mocks base method. -func (m *MockSendStreamI) CancelWrite(arg0 protocol.ApplicationErrorCode) { +func (m *MockSendStreamI) CancelWrite(arg0 ErrorCode) { m.ctrl.T.Helper() m.ctrl.Call(m, "CancelWrite", arg0) } @@ -79,24 +79,24 @@ func (mr *MockSendStreamIMockRecorder) Context() *gomock.Call { } // SetWriteDeadline mocks base method. -func (m *MockSendStreamI) SetWriteDeadline(arg0 time.Time) error { +func (m *MockSendStreamI) SetWriteDeadline(t time.Time) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SetWriteDeadline", arg0) + ret := m.ctrl.Call(m, "SetWriteDeadline", t) ret0, _ := ret[0].(error) return ret0 } // SetWriteDeadline indicates an expected call of SetWriteDeadline. -func (mr *MockSendStreamIMockRecorder) SetWriteDeadline(arg0 interface{}) *gomock.Call { +func (mr *MockSendStreamIMockRecorder) SetWriteDeadline(t interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetWriteDeadline", reflect.TypeOf((*MockSendStreamI)(nil).SetWriteDeadline), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetWriteDeadline", reflect.TypeOf((*MockSendStreamI)(nil).SetWriteDeadline), t) } // StreamID mocks base method. -func (m *MockSendStreamI) StreamID() protocol.StreamID { +func (m *MockSendStreamI) StreamID() StreamID { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "StreamID") - ret0, _ := ret[0].(protocol.StreamID) + ret0, _ := ret[0].(StreamID) return ret0 } @@ -107,18 +107,18 @@ func (mr *MockSendStreamIMockRecorder) StreamID() *gomock.Call { } // Write mocks base method. -func (m *MockSendStreamI) Write(arg0 []byte) (int, error) { +func (m *MockSendStreamI) Write(p []byte) (int, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Write", arg0) + ret := m.ctrl.Call(m, "Write", p) ret0, _ := ret[0].(int) ret1, _ := ret[1].(error) return ret0, ret1 } // Write indicates an expected call of Write. -func (mr *MockSendStreamIMockRecorder) Write(arg0 interface{}) *gomock.Call { +func (mr *MockSendStreamIMockRecorder) Write(p interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Write", reflect.TypeOf((*MockSendStreamI)(nil).Write), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Write", reflect.TypeOf((*MockSendStreamI)(nil).Write), p) } // closeForShutdown mocks base method. @@ -172,16 +172,16 @@ func (mr *MockSendStreamIMockRecorder) hasData() *gomock.Call { } // popStreamFrame mocks base method. -func (m *MockSendStreamI) popStreamFrame(arg0 protocol.ByteCount) (*ackhandler.Frame, bool) { +func (m *MockSendStreamI) popStreamFrame(maxBytes protocol.ByteCount) (*ackhandler.Frame, bool) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "popStreamFrame", arg0) + ret := m.ctrl.Call(m, "popStreamFrame", maxBytes) ret0, _ := ret[0].(*ackhandler.Frame) ret1, _ := ret[1].(bool) return ret0, ret1 } // popStreamFrame indicates an expected call of popStreamFrame. -func (mr *MockSendStreamIMockRecorder) popStreamFrame(arg0 interface{}) *gomock.Call { +func (mr *MockSendStreamIMockRecorder) popStreamFrame(maxBytes interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "popStreamFrame", reflect.TypeOf((*MockSendStreamI)(nil).popStreamFrame), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "popStreamFrame", reflect.TypeOf((*MockSendStreamI)(nil).popStreamFrame), maxBytes) } diff --git a/mock_sender_test.go b/mock_sender_test.go index 43a47678..bad5f149 100644 --- a/mock_sender_test.go +++ b/mock_sender_test.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/lucas-clemente/quic-go (interfaces: Sender) +// Source: send_queue.go // Package quic is a generated GoMock package. package quic @@ -74,15 +74,15 @@ func (mr *MockSenderMockRecorder) Run() *gomock.Call { } // Send mocks base method. -func (m *MockSender) Send(arg0 *packetBuffer) { +func (m *MockSender) Send(p *packetBuffer) { m.ctrl.T.Helper() - m.ctrl.Call(m, "Send", arg0) + m.ctrl.Call(m, "Send", p) } // Send indicates an expected call of Send. -func (mr *MockSenderMockRecorder) Send(arg0 interface{}) *gomock.Call { +func (mr *MockSenderMockRecorder) Send(p interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Send", reflect.TypeOf((*MockSender)(nil).Send), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Send", reflect.TypeOf((*MockSender)(nil).Send), p) } // WouldBlock mocks base method. diff --git a/mock_session_runner_test.go b/mock_session_runner_test.go index 7b3d5a3e..e51a1f80 100644 --- a/mock_session_runner_test.go +++ b/mock_session_runner_test.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/lucas-clemente/quic-go (interfaces: SessionRunner) +// Source: session.go // Package quic is a generated GoMock package. package quic diff --git a/mock_stream_getter_test.go b/mock_stream_getter_test.go index 9fc7a136..50934898 100644 --- a/mock_stream_getter_test.go +++ b/mock_stream_getter_test.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/lucas-clemente/quic-go (interfaces: StreamGetter) +// Source: session.go // Package quic is a generated GoMock package. package quic diff --git a/mock_stream_internal_test.go b/mock_stream_internal_test.go index de01cefe..16bc72fc 100644 --- a/mock_stream_internal_test.go +++ b/mock_stream_internal_test.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/lucas-clemente/quic-go (interfaces: StreamI) +// Source: stream.go // Package quic is a generated GoMock package. package quic @@ -39,7 +39,7 @@ func (m *MockStreamI) EXPECT() *MockStreamIMockRecorder { } // CancelRead mocks base method. -func (m *MockStreamI) CancelRead(arg0 protocol.ApplicationErrorCode) { +func (m *MockStreamI) CancelRead(arg0 ErrorCode) { m.ctrl.T.Helper() m.ctrl.Call(m, "CancelRead", arg0) } @@ -51,7 +51,7 @@ func (mr *MockStreamIMockRecorder) CancelRead(arg0 interface{}) *gomock.Call { } // CancelWrite mocks base method. -func (m *MockStreamI) CancelWrite(arg0 protocol.ApplicationErrorCode) { +func (m *MockStreamI) CancelWrite(arg0 ErrorCode) { m.ctrl.T.Helper() m.ctrl.Call(m, "CancelWrite", arg0) } @@ -91,67 +91,67 @@ func (mr *MockStreamIMockRecorder) Context() *gomock.Call { } // Read mocks base method. -func (m *MockStreamI) Read(arg0 []byte) (int, error) { +func (m *MockStreamI) Read(p []byte) (int, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Read", arg0) + ret := m.ctrl.Call(m, "Read", p) ret0, _ := ret[0].(int) ret1, _ := ret[1].(error) return ret0, ret1 } // Read indicates an expected call of Read. -func (mr *MockStreamIMockRecorder) Read(arg0 interface{}) *gomock.Call { +func (mr *MockStreamIMockRecorder) Read(p interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Read", reflect.TypeOf((*MockStreamI)(nil).Read), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Read", reflect.TypeOf((*MockStreamI)(nil).Read), p) } // SetDeadline mocks base method. -func (m *MockStreamI) SetDeadline(arg0 time.Time) error { +func (m *MockStreamI) SetDeadline(t time.Time) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SetDeadline", arg0) + ret := m.ctrl.Call(m, "SetDeadline", t) ret0, _ := ret[0].(error) return ret0 } // SetDeadline indicates an expected call of SetDeadline. -func (mr *MockStreamIMockRecorder) SetDeadline(arg0 interface{}) *gomock.Call { +func (mr *MockStreamIMockRecorder) SetDeadline(t interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetDeadline", reflect.TypeOf((*MockStreamI)(nil).SetDeadline), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetDeadline", reflect.TypeOf((*MockStreamI)(nil).SetDeadline), t) } // SetReadDeadline mocks base method. -func (m *MockStreamI) SetReadDeadline(arg0 time.Time) error { +func (m *MockStreamI) SetReadDeadline(t time.Time) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SetReadDeadline", arg0) + ret := m.ctrl.Call(m, "SetReadDeadline", t) ret0, _ := ret[0].(error) return ret0 } // SetReadDeadline indicates an expected call of SetReadDeadline. -func (mr *MockStreamIMockRecorder) SetReadDeadline(arg0 interface{}) *gomock.Call { +func (mr *MockStreamIMockRecorder) SetReadDeadline(t interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetReadDeadline", reflect.TypeOf((*MockStreamI)(nil).SetReadDeadline), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetReadDeadline", reflect.TypeOf((*MockStreamI)(nil).SetReadDeadline), t) } // SetWriteDeadline mocks base method. -func (m *MockStreamI) SetWriteDeadline(arg0 time.Time) error { +func (m *MockStreamI) SetWriteDeadline(t time.Time) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SetWriteDeadline", arg0) + ret := m.ctrl.Call(m, "SetWriteDeadline", t) ret0, _ := ret[0].(error) return ret0 } // SetWriteDeadline indicates an expected call of SetWriteDeadline. -func (mr *MockStreamIMockRecorder) SetWriteDeadline(arg0 interface{}) *gomock.Call { +func (mr *MockStreamIMockRecorder) SetWriteDeadline(t interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetWriteDeadline", reflect.TypeOf((*MockStreamI)(nil).SetWriteDeadline), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetWriteDeadline", reflect.TypeOf((*MockStreamI)(nil).SetWriteDeadline), t) } // StreamID mocks base method. -func (m *MockStreamI) StreamID() protocol.StreamID { +func (m *MockStreamI) StreamID() StreamID { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "StreamID") - ret0, _ := ret[0].(protocol.StreamID) + ret0, _ := ret[0].(StreamID) return ret0 } @@ -162,18 +162,18 @@ func (mr *MockStreamIMockRecorder) StreamID() *gomock.Call { } // Write mocks base method. -func (m *MockStreamI) Write(arg0 []byte) (int, error) { +func (m *MockStreamI) Write(p []byte) (int, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Write", arg0) + ret := m.ctrl.Call(m, "Write", p) ret0, _ := ret[0].(int) ret1, _ := ret[1].(error) return ret0, ret1 } // Write indicates an expected call of Write. -func (mr *MockStreamIMockRecorder) Write(arg0 interface{}) *gomock.Call { +func (mr *MockStreamIMockRecorder) Write(p interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Write", reflect.TypeOf((*MockStreamI)(nil).Write), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Write", reflect.TypeOf((*MockStreamI)(nil).Write), p) } // closeForShutdown mocks base method. @@ -269,16 +269,16 @@ func (mr *MockStreamIMockRecorder) hasData() *gomock.Call { } // popStreamFrame mocks base method. -func (m *MockStreamI) popStreamFrame(arg0 protocol.ByteCount) (*ackhandler.Frame, bool) { +func (m *MockStreamI) popStreamFrame(maxBytes protocol.ByteCount) (*ackhandler.Frame, bool) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "popStreamFrame", arg0) + ret := m.ctrl.Call(m, "popStreamFrame", maxBytes) ret0, _ := ret[0].(*ackhandler.Frame) ret1, _ := ret[1].(bool) return ret0, ret1 } // popStreamFrame indicates an expected call of popStreamFrame. -func (mr *MockStreamIMockRecorder) popStreamFrame(arg0 interface{}) *gomock.Call { +func (mr *MockStreamIMockRecorder) popStreamFrame(maxBytes interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "popStreamFrame", reflect.TypeOf((*MockStreamI)(nil).popStreamFrame), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "popStreamFrame", reflect.TypeOf((*MockStreamI)(nil).popStreamFrame), maxBytes) } diff --git a/mock_stream_manager_test.go b/mock_stream_manager_test.go index 96d9a7e4..84f30108 100644 --- a/mock_stream_manager_test.go +++ b/mock_stream_manager_test.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/lucas-clemente/quic-go (interfaces: StreamManager) +// Source: session.go // Package quic is a generated GoMock package. package quic diff --git a/mock_stream_sender_test.go b/mock_stream_sender_test.go index c0c0d021..7dd9d885 100644 --- a/mock_stream_sender_test.go +++ b/mock_stream_sender_test.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/lucas-clemente/quic-go (interfaces: StreamSender) +// Source: stream.go // Package quic is a generated GoMock package. package quic diff --git a/mock_unknown_packet_handler_test.go b/mock_unknown_packet_handler_test.go index 0cc19b85..d82acf1a 100644 --- a/mock_unknown_packet_handler_test.go +++ b/mock_unknown_packet_handler_test.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/lucas-clemente/quic-go (interfaces: UnknownPacketHandler) +// Source: server.go // Package quic is a generated GoMock package. package quic diff --git a/mock_unpacker_test.go b/mock_unpacker_test.go index 2c9a41f3..0703c111 100644 --- a/mock_unpacker_test.go +++ b/mock_unpacker_test.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/lucas-clemente/quic-go (interfaces: Unpacker) +// Source: session.go // Package quic is a generated GoMock package. package quic @@ -36,16 +36,16 @@ func (m *MockUnpacker) EXPECT() *MockUnpackerMockRecorder { } // Unpack mocks base method. -func (m *MockUnpacker) Unpack(arg0 *wire.Header, arg1 time.Time, arg2 []byte) (*unpackedPacket, error) { +func (m *MockUnpacker) Unpack(hdr *wire.Header, rcvTime time.Time, data []byte) (*unpackedPacket, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Unpack", arg0, arg1, arg2) + ret := m.ctrl.Call(m, "Unpack", hdr, rcvTime, data) ret0, _ := ret[0].(*unpackedPacket) ret1, _ := ret[1].(error) return ret0, ret1 } // Unpack indicates an expected call of Unpack. -func (mr *MockUnpackerMockRecorder) Unpack(arg0, arg1, arg2 interface{}) *gomock.Call { +func (mr *MockUnpackerMockRecorder) Unpack(hdr, rcvTime, data interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Unpack", reflect.TypeOf((*MockUnpacker)(nil).Unpack), arg0, arg1, arg2) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Unpack", reflect.TypeOf((*MockUnpacker)(nil).Unpack), hdr, rcvTime, data) } diff --git a/mockgen_private.sh b/mockgen_private.sh index f0855bbf..15c3c513 100755 --- a/mockgen_private.sh +++ b/mockgen_private.sh @@ -1,16 +1,51 @@ #!/bin/bash +DEST=$2 PACKAGE=$3 TMPFILE="mockgen_tmp.go" # uppercase the name of the interface -INTERFACE_NAME="$(tr '[:lower:]' '[:upper:]' <<< ${4:0:1})${4:1}" +ORIG_INTERFACE_NAME=$4 +INTERFACE_NAME="$(tr '[:lower:]' '[:upper:]' <<< ${ORIG_INTERFACE_NAME:0:1})${ORIG_INTERFACE_NAME:1}" -# create a public alias for the interface, so that mockgen can process it +# Gather all files that contain interface definitions. +# These interfaces might be used as embedded interfaces, +# so we need to pass them to mockgen as aux_files. +AUX=() +for f in *.go; do + if [[ -z ${f##*_test.go} ]]; then + # skip test files + continue; + fi + if $(egrep -qe "type (.*) interface" $f); then + AUX+=("github.com/lucas-clemente/quic-go=$f") + fi +done + +# Find the file that defines the interface we're mocking. +for f in *.go; do + if [[ -z ${f##*_test.go} ]]; then + # skip test files + continue; + fi + INTERFACE=$(sed -n "/^type $ORIG_INTERFACE_NAME interface/,/^}/p" $f) + if [[ -n "$INTERFACE" ]]; then + SRC=$f + break + fi +done + +if [[ -z "$INTERFACE" ]]; then + echo "Interface $ORIG_INTERFACE_NAME not found." + exit 1 +fi + +AUX_FILES=$(IFS=, ; echo "${AUX[*]}") + +## create a public alias for the interface, so that mockgen can process it echo -e "package $1\n" > $TMPFILE -echo "type $INTERFACE_NAME = $4" >> $TMPFILE - -mockgen -package $1 -self_package $PACKAGE -destination $2 $PACKAGE $INTERFACE_NAME -mv $2 $TMPFILE && sed 's/qtls.ConnectionState/ConnectionState/g' $TMPFILE > $2 -goimports -w $2 - -rm $TMPFILE +echo "$INTERFACE" | sed "s/$ORIG_INTERFACE_NAME/$INTERFACE_NAME/" >> $TMPFILE +goimports -w $TMPFILE +mockgen -package $1 -self_package $3 -destination $DEST -source=$TMPFILE -aux_files $AUX_FILES +goimports -w $DEST +sed "s/$TMPFILE/$SRC/" "$DEST" > "$DEST.new" && mv "$DEST.new" "$DEST" +rm "$TMPFILE"