mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-05 05:07:36 +03:00
move the logging mock implementations to a separate package
This commit is contained in:
parent
bed802aee5
commit
e0824e3163
9 changed files with 30 additions and 30 deletions
|
@ -9,15 +9,15 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/lucas-clemente/quic-go/logging"
|
mocklogging "github.com/lucas-clemente/quic-go/internal/mocks/logging"
|
||||||
|
|
||||||
"github.com/golang/mock/gomock"
|
|
||||||
"github.com/lucas-clemente/quic-go/internal/mocks"
|
|
||||||
"github.com/lucas-clemente/quic-go/internal/protocol"
|
"github.com/lucas-clemente/quic-go/internal/protocol"
|
||||||
"github.com/lucas-clemente/quic-go/internal/utils"
|
"github.com/lucas-clemente/quic-go/internal/utils"
|
||||||
"github.com/lucas-clemente/quic-go/internal/wire"
|
"github.com/lucas-clemente/quic-go/internal/wire"
|
||||||
|
"github.com/lucas-clemente/quic-go/logging"
|
||||||
"github.com/lucas-clemente/quic-go/quictrace"
|
"github.com/lucas-clemente/quic-go/quictrace"
|
||||||
|
|
||||||
|
"github.com/golang/mock/gomock"
|
||||||
|
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
)
|
)
|
||||||
|
@ -31,7 +31,7 @@ var _ = Describe("Client", func() {
|
||||||
mockMultiplexer *MockMultiplexer
|
mockMultiplexer *MockMultiplexer
|
||||||
origMultiplexer multiplexer
|
origMultiplexer multiplexer
|
||||||
tlsConf *tls.Config
|
tlsConf *tls.Config
|
||||||
tracer *mocks.MockConnectionTracer
|
tracer *mocklogging.MockConnectionTracer
|
||||||
config *Config
|
config *Config
|
||||||
|
|
||||||
originalClientSessConstructor func(
|
originalClientSessConstructor func(
|
||||||
|
@ -66,8 +66,8 @@ var _ = Describe("Client", func() {
|
||||||
tlsConf = &tls.Config{NextProtos: []string{"proto1"}}
|
tlsConf = &tls.Config{NextProtos: []string{"proto1"}}
|
||||||
connID = protocol.ConnectionID{0, 0, 0, 0, 0, 0, 0x13, 0x37}
|
connID = protocol.ConnectionID{0, 0, 0, 0, 0, 0, 0x13, 0x37}
|
||||||
originalClientSessConstructor = newClientSession
|
originalClientSessConstructor = newClientSession
|
||||||
tracer = mocks.NewMockConnectionTracer(mockCtrl)
|
tracer = mocklogging.NewMockConnectionTracer(mockCtrl)
|
||||||
tr := mocks.NewMockTracer(mockCtrl)
|
tr := mocklogging.NewMockTracer(mockCtrl)
|
||||||
tr.EXPECT().TracerForConnection(protocol.PerspectiveClient, gomock.Any()).Return(tracer).MaxTimes(1)
|
tr.EXPECT().TracerForConnection(protocol.PerspectiveClient, gomock.Any()).Return(tracer).MaxTimes(1)
|
||||||
config = &Config{Tracer: tr}
|
config = &Config{Tracer: tr}
|
||||||
Eventually(areSessionsRunning).Should(BeFalse())
|
Eventually(areSessionsRunning).Should(BeFalse())
|
||||||
|
|
|
@ -6,7 +6,7 @@ import (
|
||||||
"reflect"
|
"reflect"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/lucas-clemente/quic-go/internal/mocks"
|
mocklogging "github.com/lucas-clemente/quic-go/internal/mocks/logging"
|
||||||
"github.com/lucas-clemente/quic-go/internal/protocol"
|
"github.com/lucas-clemente/quic-go/internal/protocol"
|
||||||
"github.com/lucas-clemente/quic-go/quictrace"
|
"github.com/lucas-clemente/quic-go/quictrace"
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ var _ = Describe("Config", func() {
|
||||||
case "QuicTracer":
|
case "QuicTracer":
|
||||||
f.Set(reflect.ValueOf(quictrace.NewTracer()))
|
f.Set(reflect.ValueOf(quictrace.NewTracer()))
|
||||||
case "Tracer":
|
case "Tracer":
|
||||||
f.Set(reflect.ValueOf(mocks.NewMockTracer(mockCtrl)))
|
f.Set(reflect.ValueOf(mocklogging.NewMockTracer(mockCtrl)))
|
||||||
default:
|
default:
|
||||||
Fail(fmt.Sprintf("all fields must be accounted for, but saw unknown field %q", fn))
|
Fail(fmt.Sprintf("all fields must be accounted for, but saw unknown field %q", fn))
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
// Code generated by MockGen. DO NOT EDIT.
|
// Code generated by MockGen. DO NOT EDIT.
|
||||||
// Source: github.com/lucas-clemente/quic-go/logging (interfaces: ConnectionTracer)
|
// Source: github.com/lucas-clemente/quic-go/logging (interfaces: ConnectionTracer)
|
||||||
|
|
||||||
// Package mocks is a generated GoMock package.
|
// Package mocklogging is a generated GoMock package.
|
||||||
package mocks
|
package mocklogging
|
||||||
|
|
||||||
import (
|
import (
|
||||||
net "net"
|
net "net"
|
|
@ -1,8 +1,8 @@
|
||||||
// Code generated by MockGen. DO NOT EDIT.
|
// Code generated by MockGen. DO NOT EDIT.
|
||||||
// Source: github.com/lucas-clemente/quic-go/logging (interfaces: Tracer)
|
// Source: github.com/lucas-clemente/quic-go/logging (interfaces: Tracer)
|
||||||
|
|
||||||
// Package mocks is a generated GoMock package.
|
// Package mocklogging is a generated GoMock package.
|
||||||
package mocks
|
package mocklogging
|
||||||
|
|
||||||
import (
|
import (
|
||||||
net "net"
|
net "net"
|
|
@ -3,8 +3,8 @@ package mocks
|
||||||
//go:generate sh -c "mockgen -package mockquic -destination quic/stream.go github.com/lucas-clemente/quic-go Stream && goimports -w quic/stream.go"
|
//go:generate sh -c "mockgen -package mockquic -destination quic/stream.go github.com/lucas-clemente/quic-go Stream && goimports -w quic/stream.go"
|
||||||
//go:generate sh -c "mockgen -package mockquic -destination quic/early_session_tmp.go github.com/lucas-clemente/quic-go EarlySession && sed 's/qtls.ConnectionState/quic.ConnectionState/g' quic/early_session_tmp.go > quic/early_session.go && rm quic/early_session_tmp.go && goimports -w quic/early_session.go"
|
//go:generate sh -c "mockgen -package mockquic -destination quic/early_session_tmp.go github.com/lucas-clemente/quic-go EarlySession && sed 's/qtls.ConnectionState/quic.ConnectionState/g' quic/early_session_tmp.go > quic/early_session.go && rm quic/early_session_tmp.go && goimports -w quic/early_session.go"
|
||||||
//go:generate sh -c "mockgen -package mockquic -destination quic/early_listener.go github.com/lucas-clemente/quic-go EarlyListener && goimports -w quic/early_listener.go"
|
//go:generate sh -c "mockgen -package mockquic -destination quic/early_listener.go github.com/lucas-clemente/quic-go EarlyListener && goimports -w quic/early_listener.go"
|
||||||
//go:generate sh -c "mockgen -package mocks -destination tracer.go github.com/lucas-clemente/quic-go/logging Tracer && goimports -w tracer.go"
|
//go:generate sh -c "mockgen -package mocklogging -destination logging/tracer.go github.com/lucas-clemente/quic-go/logging Tracer && goimports -w logging/tracer.go"
|
||||||
//go:generate sh -c "mockgen -package mocks -destination connection_tracer.go github.com/lucas-clemente/quic-go/logging ConnectionTracer && goimports -w connection_tracer.go"
|
//go:generate sh -c "mockgen -package mocklogging -destination logging/connection_tracer.go github.com/lucas-clemente/quic-go/logging ConnectionTracer && goimports -w logging/connection_tracer.go"
|
||||||
//go:generate sh -c "mockgen -package mocks -destination short_header_sealer.go github.com/lucas-clemente/quic-go/internal/handshake ShortHeaderSealer && goimports -w short_header_sealer.go"
|
//go:generate sh -c "mockgen -package mocks -destination short_header_sealer.go github.com/lucas-clemente/quic-go/internal/handshake ShortHeaderSealer && goimports -w short_header_sealer.go"
|
||||||
//go:generate sh -c "mockgen -package mocks -destination short_header_opener.go github.com/lucas-clemente/quic-go/internal/handshake ShortHeaderOpener && goimports -w short_header_opener.go"
|
//go:generate sh -c "mockgen -package mocks -destination short_header_opener.go github.com/lucas-clemente/quic-go/internal/handshake ShortHeaderOpener && goimports -w short_header_opener.go"
|
||||||
//go:generate sh -c "mockgen -package mocks -destination long_header_opener.go github.com/lucas-clemente/quic-go/internal/handshake LongHeaderOpener && goimports -w long_header_opener.go"
|
//go:generate sh -c "mockgen -package mocks -destination long_header_opener.go github.com/lucas-clemente/quic-go/internal/handshake LongHeaderOpener && goimports -w long_header_opener.go"
|
||||||
|
|
|
@ -3,7 +3,7 @@ package quic
|
||||||
import (
|
import (
|
||||||
"net"
|
"net"
|
||||||
|
|
||||||
"github.com/lucas-clemente/quic-go/internal/mocks"
|
mocklogging "github.com/lucas-clemente/quic-go/internal/mocks/logging"
|
||||||
|
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
|
@ -25,7 +25,7 @@ var _ = Describe("Client Multiplexer", func() {
|
||||||
pconn := newMockPacketConn()
|
pconn := newMockPacketConn()
|
||||||
pconn.addr = &net.UDPAddr{IP: net.IPv4(1, 2, 3, 4), Port: 4321}
|
pconn.addr = &net.UDPAddr{IP: net.IPv4(1, 2, 3, 4), Port: 4321}
|
||||||
conn := testConn{PacketConn: pconn}
|
conn := testConn{PacketConn: pconn}
|
||||||
tracer := mocks.NewMockTracer(mockCtrl)
|
tracer := mocklogging.NewMockTracer(mockCtrl)
|
||||||
_, err := getMultiplexer().AddConn(conn, 8, []byte("foobar"), tracer)
|
_, err := getMultiplexer().AddConn(conn, 8, []byte("foobar"), tracer)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
conn.counter++
|
conn.counter++
|
||||||
|
@ -52,9 +52,9 @@ var _ = Describe("Client Multiplexer", func() {
|
||||||
|
|
||||||
It("errors when adding an existing conn with different tracers", func() {
|
It("errors when adding an existing conn with different tracers", func() {
|
||||||
conn := newMockPacketConn()
|
conn := newMockPacketConn()
|
||||||
_, err := getMultiplexer().AddConn(conn, 7, nil, mocks.NewMockTracer(mockCtrl))
|
_, err := getMultiplexer().AddConn(conn, 7, nil, mocklogging.NewMockTracer(mockCtrl))
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
_, err = getMultiplexer().AddConn(conn, 7, nil, mocks.NewMockTracer(mockCtrl))
|
_, err = getMultiplexer().AddConn(conn, 7, nil, mocklogging.NewMockTracer(mockCtrl))
|
||||||
Expect(err).To(MatchError("cannot use different tracers on the same packet conn"))
|
Expect(err).To(MatchError("cannot use different tracers on the same packet conn"))
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -7,7 +7,7 @@ import (
|
||||||
"net"
|
"net"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/lucas-clemente/quic-go/internal/mocks"
|
mocklogging "github.com/lucas-clemente/quic-go/internal/mocks/logging"
|
||||||
"github.com/lucas-clemente/quic-go/internal/protocol"
|
"github.com/lucas-clemente/quic-go/internal/protocol"
|
||||||
"github.com/lucas-clemente/quic-go/internal/utils"
|
"github.com/lucas-clemente/quic-go/internal/utils"
|
||||||
"github.com/lucas-clemente/quic-go/internal/wire"
|
"github.com/lucas-clemente/quic-go/internal/wire"
|
||||||
|
@ -23,7 +23,7 @@ var _ = Describe("Packet Handler Map", func() {
|
||||||
var (
|
var (
|
||||||
handler *packetHandlerMap
|
handler *packetHandlerMap
|
||||||
conn *mockPacketConn
|
conn *mockPacketConn
|
||||||
tracer *mocks.MockTracer
|
tracer *mocklogging.MockTracer
|
||||||
|
|
||||||
connIDLen int
|
connIDLen int
|
||||||
statelessResetKey []byte
|
statelessResetKey []byte
|
||||||
|
@ -51,7 +51,7 @@ var _ = Describe("Packet Handler Map", func() {
|
||||||
BeforeEach(func() {
|
BeforeEach(func() {
|
||||||
statelessResetKey = nil
|
statelessResetKey = nil
|
||||||
connIDLen = 0
|
connIDLen = 0
|
||||||
tracer = mocks.NewMockTracer(mockCtrl)
|
tracer = mocklogging.NewMockTracer(mockCtrl)
|
||||||
})
|
})
|
||||||
|
|
||||||
JustBeforeEach(func() {
|
JustBeforeEach(func() {
|
||||||
|
|
|
@ -14,9 +14,8 @@ import (
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/lucas-clemente/quic-go/internal/mocks"
|
|
||||||
|
|
||||||
"github.com/lucas-clemente/quic-go/internal/handshake"
|
"github.com/lucas-clemente/quic-go/internal/handshake"
|
||||||
|
mocklogging "github.com/lucas-clemente/quic-go/internal/mocks/logging"
|
||||||
"github.com/lucas-clemente/quic-go/internal/protocol"
|
"github.com/lucas-clemente/quic-go/internal/protocol"
|
||||||
"github.com/lucas-clemente/quic-go/internal/qerr"
|
"github.com/lucas-clemente/quic-go/internal/qerr"
|
||||||
"github.com/lucas-clemente/quic-go/internal/testdata"
|
"github.com/lucas-clemente/quic-go/internal/testdata"
|
||||||
|
@ -186,11 +185,11 @@ var _ = Describe("Server", func() {
|
||||||
var (
|
var (
|
||||||
serv *baseServer
|
serv *baseServer
|
||||||
phm *MockPacketHandlerManager
|
phm *MockPacketHandlerManager
|
||||||
tracer *mocks.MockTracer
|
tracer *mocklogging.MockTracer
|
||||||
)
|
)
|
||||||
|
|
||||||
BeforeEach(func() {
|
BeforeEach(func() {
|
||||||
tracer = mocks.NewMockTracer(mockCtrl)
|
tracer = mocklogging.NewMockTracer(mockCtrl)
|
||||||
ln, err := Listen(conn, tlsConf, &Config{Tracer: tracer})
|
ln, err := Listen(conn, tlsConf, &Config{Tracer: tracer})
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
serv = ln.(*baseServer)
|
serv = ln.(*baseServer)
|
||||||
|
|
|
@ -17,6 +17,7 @@ import (
|
||||||
"github.com/lucas-clemente/quic-go/internal/handshake"
|
"github.com/lucas-clemente/quic-go/internal/handshake"
|
||||||
"github.com/lucas-clemente/quic-go/internal/mocks"
|
"github.com/lucas-clemente/quic-go/internal/mocks"
|
||||||
mockackhandler "github.com/lucas-clemente/quic-go/internal/mocks/ackhandler"
|
mockackhandler "github.com/lucas-clemente/quic-go/internal/mocks/ackhandler"
|
||||||
|
mocklogging "github.com/lucas-clemente/quic-go/internal/mocks/logging"
|
||||||
"github.com/lucas-clemente/quic-go/internal/protocol"
|
"github.com/lucas-clemente/quic-go/internal/protocol"
|
||||||
"github.com/lucas-clemente/quic-go/internal/qerr"
|
"github.com/lucas-clemente/quic-go/internal/qerr"
|
||||||
"github.com/lucas-clemente/quic-go/internal/testutils"
|
"github.com/lucas-clemente/quic-go/internal/testutils"
|
||||||
|
@ -50,7 +51,7 @@ var _ = Describe("Session", func() {
|
||||||
streamManager *MockStreamManager
|
streamManager *MockStreamManager
|
||||||
packer *MockPacker
|
packer *MockPacker
|
||||||
cryptoSetup *mocks.MockCryptoSetup
|
cryptoSetup *mocks.MockCryptoSetup
|
||||||
tracer *mocks.MockConnectionTracer
|
tracer *mocklogging.MockConnectionTracer
|
||||||
)
|
)
|
||||||
remoteAddr := &net.UDPAddr{IP: net.IPv4(127, 0, 0, 1), Port: 1337}
|
remoteAddr := &net.UDPAddr{IP: net.IPv4(127, 0, 0, 1), Port: 1337}
|
||||||
localAddr := &net.UDPAddr{IP: net.IPv4(127, 0, 0, 1), Port: 7331}
|
localAddr := &net.UDPAddr{IP: net.IPv4(127, 0, 0, 1), Port: 7331}
|
||||||
|
@ -88,7 +89,7 @@ var _ = Describe("Session", func() {
|
||||||
mconn.EXPECT().LocalAddr().Return(localAddr).AnyTimes()
|
mconn.EXPECT().LocalAddr().Return(localAddr).AnyTimes()
|
||||||
tokenGenerator, err := handshake.NewTokenGenerator(rand.Reader)
|
tokenGenerator, err := handshake.NewTokenGenerator(rand.Reader)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
tracer = mocks.NewMockConnectionTracer(mockCtrl)
|
tracer = mocklogging.NewMockConnectionTracer(mockCtrl)
|
||||||
tracer.EXPECT().SentTransportParameters(gomock.Any())
|
tracer.EXPECT().SentTransportParameters(gomock.Any())
|
||||||
tracer.EXPECT().UpdatedKeyFromTLS(gomock.Any(), gomock.Any()).AnyTimes()
|
tracer.EXPECT().UpdatedKeyFromTLS(gomock.Any(), gomock.Any()).AnyTimes()
|
||||||
tracer.EXPECT().UpdatedCongestionState(gomock.Any())
|
tracer.EXPECT().UpdatedCongestionState(gomock.Any())
|
||||||
|
@ -2109,7 +2110,7 @@ var _ = Describe("Client Session", func() {
|
||||||
packer *MockPacker
|
packer *MockPacker
|
||||||
mconn *MockSendConn
|
mconn *MockSendConn
|
||||||
cryptoSetup *mocks.MockCryptoSetup
|
cryptoSetup *mocks.MockCryptoSetup
|
||||||
tracer *mocks.MockConnectionTracer
|
tracer *mocklogging.MockConnectionTracer
|
||||||
tlsConf *tls.Config
|
tlsConf *tls.Config
|
||||||
quicConf *Config
|
quicConf *Config
|
||||||
)
|
)
|
||||||
|
@ -2148,7 +2149,7 @@ var _ = Describe("Client Session", func() {
|
||||||
tlsConf = &tls.Config{}
|
tlsConf = &tls.Config{}
|
||||||
}
|
}
|
||||||
sessionRunner = NewMockSessionRunner(mockCtrl)
|
sessionRunner = NewMockSessionRunner(mockCtrl)
|
||||||
tracer = mocks.NewMockConnectionTracer(mockCtrl)
|
tracer = mocklogging.NewMockConnectionTracer(mockCtrl)
|
||||||
tracer.EXPECT().SentTransportParameters(gomock.Any())
|
tracer.EXPECT().SentTransportParameters(gomock.Any())
|
||||||
tracer.EXPECT().UpdatedKeyFromTLS(gomock.Any(), gomock.Any()).AnyTimes()
|
tracer.EXPECT().UpdatedKeyFromTLS(gomock.Any(), gomock.Any()).AnyTimes()
|
||||||
tracer.EXPECT().UpdatedCongestionState(gomock.Any())
|
tracer.EXPECT().UpdatedCongestionState(gomock.Any())
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue