Skip to content

Commit

Permalink
simplify mockgen usage for private interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
marten-seemann committed Apr 12, 2023
1 parent af517bd commit eebf3f1
Show file tree
Hide file tree
Showing 35 changed files with 325 additions and 310 deletions.
20 changes: 10 additions & 10 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ var _ = Describe("Client", func() {
_ protocol.VersionNumber,
) quicConn {
remoteAddrChan <- sconn.RemoteAddr().String()
conn := NewMockQuicConn(mockCtrl)
conn := NewMockQUICConn(mockCtrl)
conn.EXPECT().run()
conn.EXPECT().HandshakeComplete().Return(make(chan struct{}))
return conn
Expand Down Expand Up @@ -161,7 +161,7 @@ var _ = Describe("Client", func() {
_ protocol.VersionNumber,
) quicConn {
hostnameChan <- tlsConf.ServerName
conn := NewMockQuicConn(mockCtrl)
conn := NewMockQUICConn(mockCtrl)
conn.EXPECT().run()
conn.EXPECT().HandshakeComplete().Return(make(chan struct{}))
return conn
Expand Down Expand Up @@ -194,7 +194,7 @@ var _ = Describe("Client", func() {
_ protocol.VersionNumber,
) quicConn {
hostnameChan <- tlsConf.ServerName
conn := NewMockQuicConn(mockCtrl)
conn := NewMockQUICConn(mockCtrl)
conn.EXPECT().HandshakeComplete().Return(make(chan struct{}))
conn.EXPECT().run()
return conn
Expand Down Expand Up @@ -233,7 +233,7 @@ var _ = Describe("Client", func() {
_ protocol.VersionNumber,
) quicConn {
Expect(enable0RTT).To(BeFalse())
conn := NewMockQuicConn(mockCtrl)
conn := NewMockQUICConn(mockCtrl)
conn.EXPECT().run().Do(func() { close(run) })
c := make(chan struct{})
close(c)
Expand Down Expand Up @@ -276,7 +276,7 @@ var _ = Describe("Client", func() {
_ protocol.VersionNumber,
) quicConn {
Expect(enable0RTT).To(BeTrue())
conn := NewMockQuicConn(mockCtrl)
conn := NewMockQUICConn(mockCtrl)
conn.EXPECT().run().Do(func() { <-done })
conn.EXPECT().HandshakeComplete().Return(make(chan struct{}))
conn.EXPECT().earlyConnReady().Return(readyChan)
Expand Down Expand Up @@ -323,7 +323,7 @@ var _ = Describe("Client", func() {
_ utils.Logger,
_ protocol.VersionNumber,
) quicConn {
conn := NewMockQuicConn(mockCtrl)
conn := NewMockQUICConn(mockCtrl)
conn.EXPECT().run().Return(testErr)
conn.EXPECT().HandshakeComplete().Return(make(chan struct{}))
return conn
Expand All @@ -346,7 +346,7 @@ var _ = Describe("Client", func() {

connRunning := make(chan struct{})
defer close(connRunning)
conn := NewMockQuicConn(mockCtrl)
conn := NewMockQUICConn(mockCtrl)
conn.EXPECT().run().Do(func() {
<-connRunning
})
Expand Down Expand Up @@ -402,7 +402,7 @@ var _ = Describe("Client", func() {
var sconn sendConn
run := make(chan struct{})
connCreated := make(chan struct{})
conn := NewMockQuicConn(mockCtrl)
conn := NewMockQUICConn(mockCtrl)
newClientConnection = func(
connP sendConn,
_ connRunner,
Expand Down Expand Up @@ -544,7 +544,7 @@ var _ = Describe("Client", func() {
conf = configP
close(c)
// TODO: check connection IDs?
conn := NewMockQuicConn(mockCtrl)
conn := NewMockQUICConn(mockCtrl)
conn.EXPECT().run()
conn.EXPECT().HandshakeComplete().Return(make(chan struct{}))
return conn
Expand Down Expand Up @@ -579,7 +579,7 @@ var _ = Describe("Client", func() {
_ utils.Logger,
versionP protocol.VersionNumber,
) quicConn {
conn := NewMockQuicConn(mockCtrl)
conn := NewMockQUICConn(mockCtrl)
conn.EXPECT().HandshakeComplete().Return(make(chan struct{}))
if counter == 0 {
Expect(pn).To(BeZero())
Expand Down
2 changes: 1 addition & 1 deletion connection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1631,7 +1631,7 @@ var _ = Describe("Connection", func() {
})

It("sends a Path MTU probe packet", func() {
mtuDiscoverer := NewMockMtuDiscoverer(mockCtrl)
mtuDiscoverer := NewMockMTUDiscoverer(mockCtrl)
conn.mtuDiscoverer = mtuDiscoverer
conn.config.DisablePathMTUDiscovery = false
sph.EXPECT().SentPacket(gomock.Any())
Expand Down
2 changes: 1 addition & 1 deletion http3/mock_roundtripcloser_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions http3/mockgen.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
//go:build gomock || generate

package http3

//go:generate sh -c "go run github.com/golang/mock/mockgen -build_flags=\"-tags=gomock\" -package http3 -destination mock_roundtripcloser_test.go github.com/quic-go/quic-go/http3 RoundTripCloser"
type RoundTripCloser = roundTripCloser
2 changes: 0 additions & 2 deletions http3/roundtrip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ import (
. "github.com/onsi/gomega"
)

//go:generate sh -c "./../mockgen_private.sh http3 mock_roundtripcloser_test.go github.com/quic-go/quic-go/http3 roundTripCloser"

type mockBody struct {
reader bytes.Reader
readErr error
Expand Down
2 changes: 1 addition & 1 deletion internal/ackhandler/mock_sent_packet_tracker_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion internal/ackhandler/mockgen.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//go:build gomock || generate

package ackhandler

//go:generate sh -c "../../mockgen_private.sh ackhandler mock_sent_packet_tracker_test.go github.com/quic-go/quic-go/internal/ackhandler sentPacketTracker"
//go:generate sh -c "go run github.com/golang/mock/mockgen -build_flags=\"-tags=gomock\" -package ackhandler -destination mock_sent_packet_tracker_test.go github.com/quic-go/quic-go/internal/ackhandler SentPacketTracker"
type SentPacketTracker = sentPacketTracker
2 changes: 1 addition & 1 deletion internal/handshake/mock_handshake_runner_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion internal/handshake/mockgen.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//go:build gomock || generate

package handshake

//go:generate sh -c "../../mockgen_private.sh handshake mock_handshake_runner_test.go github.com/quic-go/quic-go/internal/handshake handshakeRunner"
//go:generate sh -c "go run github.com/golang/mock/mockgen -build_flags=\"-tags=gomock\" -package handshake -destination mock_handshake_runner_test.go github.com/quic-go/quic-go/internal/handshake HandshakeRunner"
type HandshakeRunner = handshakeRunner
10 changes: 5 additions & 5 deletions mock_ack_frame_source_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion mock_batch_conn_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion mock_conn_runner_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion mock_crypto_data_handler_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions mock_crypto_stream_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion mock_frame_source_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 19 additions & 19 deletions mock_mtu_discoverer_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions mock_multiplexer_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit eebf3f1

Please sign in to comment.