From a8377c07acdb9482ec5b5053f41342f8a8967deb Mon Sep 17 00:00:00 2001 From: Julien Laffaye Date: Tue, 8 Mar 2022 19:06:48 -0500 Subject: [PATCH] Add test for DialWithDialFunc --- client_test.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/client_test.go b/client_test.go index 95eb5a9..67d3433 100644 --- a/client_test.go +++ b/client_test.go @@ -2,7 +2,9 @@ package ftp import ( "bytes" + "fmt" "io/ioutil" + "net" "net/textproto" "strings" "testing" @@ -404,3 +406,14 @@ func TestTimeVsftpdFull(t *testing.T) { assert.NoError(t, c.Quit()) mock.Wait() } + +func TestDialWithDialFunc(t *testing.T) { + dialErr := fmt.Errorf("this is proof that dial function was called") + + f := func(network, address string) (net.Conn, error) { + return nil, dialErr + } + + _, err := Dial("bogus-address", DialWithDialFunc(f)) + assert.Equal(t, dialErr, err) +}