refactor: rename i/e/n/mockablex => i/netxmocks (#397)

Needed to more easily do https://github.com/ooni/probe/issues/1505
This commit is contained in:
Simone Basso
2021-06-23 16:06:02 +02:00
committed by GitHub
parent 8a0beee808
commit 16aa8e5538
16 changed files with 44 additions and 44 deletions
+4 -4
View File
@@ -8,7 +8,7 @@ import (
"testing"
"github.com/ooni/probe-cli/v3/internal/atomicx"
"github.com/ooni/probe-cli/v3/internal/engine/netx/mockablex"
"github.com/ooni/probe-cli/v3/internal/netxmocks"
)
func TestOBFS4DialerWorks(t *testing.T) {
@@ -48,7 +48,7 @@ func TestOBFS4DialerFailsWithInvalidCert(t *testing.T) {
func TestOBFS4DialerFailsWithConnectionErrorAndNoContextExpiration(t *testing.T) {
expected := errors.New("mocked error")
o4d := DefaultTestingOBFS4Bridge()
o4d.UnderlyingDialer = &mockablex.Dialer{
o4d.UnderlyingDialer = &netxmocks.Dialer{
MockDialContext: func(ctx context.Context, network string, address string) (net.Conn, error) {
return nil, expected
},
@@ -67,7 +67,7 @@ func TestOBFS4DialerFailsWithConnectionErrorAndContextExpiration(t *testing.T) {
defer cancel()
expected := errors.New("mocked error")
o4d := DefaultTestingOBFS4Bridge()
o4d.UnderlyingDialer = &mockablex.Dialer{
o4d.UnderlyingDialer = &netxmocks.Dialer{
MockDialContext: func(ctx context.Context, network string, address string) (net.Conn, error) {
// We cancel the context before returning the error, which makes
// the context cancellation happen before us returning.
@@ -101,7 +101,7 @@ func TestOBFS4DialerWorksWithContextExpiration(t *testing.T) {
defer cancel()
called := &atomicx.Int64{}
o4d := DefaultTestingOBFS4Bridge()
o4d.UnderlyingDialer = &mockablex.Dialer{
o4d.UnderlyingDialer = &netxmocks.Dialer{
MockDialContext: func(ctx context.Context, network string, address string) (net.Conn, error) {
// We cancel the context before returning the error, which makes
// the context cancellation happen before us returning.
+4 -4
View File
@@ -13,8 +13,8 @@ import (
"github.com/apex/log"
"github.com/ooni/probe-cli/v3/internal/atomicx"
"github.com/ooni/probe-cli/v3/internal/engine/netx/mockablex"
"github.com/ooni/probe-cli/v3/internal/iox"
"github.com/ooni/probe-cli/v3/internal/netxmocks"
)
func TestListenerLoggerWorks(t *testing.T) {
@@ -96,8 +96,8 @@ func TestListenerCastListenerWorksFineOnError(t *testing.T) {
// mockableSocksConn is a mockable ptxSocksConn.
type mockableSocksConn struct {
// mockablex.Conn allows to mock all net.Conn functionality.
*mockablex.Conn
// netxmocks.Conn allows to mock all net.Conn functionality.
*netxmocks.Conn
// MockGrant allows to mock the Grant function.
MockGrant func(addr *net.TCPAddr) error
@@ -160,7 +160,7 @@ func TestListenerHandleSocksConnWithDialContextFailure(t *testing.T) {
}
lst := &Listener{PTDialer: d}
c := &mockableSocksConn{
Conn: &mockablex.Conn{
Conn: &netxmocks.Conn{
MockClose: func() error {
return nil
},
+3 -3
View File
@@ -7,7 +7,7 @@ import (
"testing"
"github.com/ooni/probe-cli/v3/internal/atomicx"
"github.com/ooni/probe-cli/v3/internal/engine/netx/mockablex"
"github.com/ooni/probe-cli/v3/internal/netxmocks"
)
func TestSnowflakeDialerWorks(t *testing.T) {
@@ -50,7 +50,7 @@ func TestSnowflakeDialerWorksWithMocks(t *testing.T) {
newClientTransport: func(brokerURL, frontDomain string, iceAddresses []string, keepLocalAddresses bool, maxSnowflakes int) (snowflakeTransport, error) {
return &mockableSnowflakeTransport{
MockDial: func() (net.Conn, error) {
return &mockablex.Conn{
return &netxmocks.Conn{
MockClose: func() error {
return nil
},
@@ -144,7 +144,7 @@ func TestSnowflakeDialerWorksWithWithCancelledContext(t *testing.T) {
return &mockableSnowflakeTransport{
MockDial: func() (net.Conn, error) {
cancel() // cause a cancel before we can really have a conn
return &mockablex.Conn{
return &netxmocks.Conn{
MockClose: func() error {
called.Add(1)
return nil