32 lines
691 B
Go
32 lines
691 B
Go
package dialer_test
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"io"
|
|
"net"
|
|
"testing"
|
|
|
|
"github.com/apex/log"
|
|
"github.com/ooni/probe-cli/v3/internal/engine/netx/dialer"
|
|
"github.com/ooni/probe-cli/v3/internal/engine/netx/mockablex"
|
|
)
|
|
|
|
func TestLoggingDialerFailure(t *testing.T) {
|
|
d := dialer.LoggingDialer{
|
|
Dialer: mockablex.Dialer{
|
|
MockDialContext: func(ctx context.Context, network string, address string) (net.Conn, error) {
|
|
return nil, io.EOF
|
|
},
|
|
},
|
|
Logger: log.Log,
|
|
}
|
|
conn, err := d.DialContext(context.Background(), "tcp", "www.google.com:443")
|
|
if !errors.Is(err, io.EOF) {
|
|
t.Fatal("not the error we expected")
|
|
}
|
|
if conn != nil {
|
|
t.Fatal("expected nil conn here")
|
|
}
|
|
}
|