Skip to content
Permalink
Branch: master
Commits on May 13, 2019
  1. Add missing newline

    tlux committed May 13, 2019
  2. Fix wrong var name in docs

    tlux committed May 13, 2019
  3. Add Hex version badge

    tlux committed May 13, 2019
  4. Add types to exception structs

    tlux committed May 13, 2019
  5. Use non-raising variants of close_handle in open_file and open_dir op…

    tlux committed May 13, 2019
    …erations
  6. Improve connect example

    tlux committed May 13, 2019
  7. Add auto-closing variants of open_file, open_dir and connect functions

    tlux committed May 13, 2019
  8. Fix most of the tests

    tlux committed May 13, 2019
    diff --git a/lib/sftp_client/adapter/sftp.ex b/lib/sftp_client/adapter/sftp.ex
    index d0a23c5..e297ad7 100644
    --- a/lib/sftp_client/adapter/sftp.ex
    +++ b/lib/sftp_client/adapter/sftp.ex
    @@ -14,11 +14,14 @@ defmodule SFTPClient.Adapter.SFTP do
       @callback list_dir(channel_pid :: pid, path :: charlist, timeout) ::
                   {:ok, [charlist]} | {:error, any}
    
    -  @callback close(channel_pid :: pid, handle :: term, timeout) :: :ok | {:error, any}
    +  @callback close(channel_pid :: pid, handle :: term, timeout) ::
    +              :ok | {:error, any}
    
    -  @callback del_dir(channel_pid :: pid, path :: charlist, timeout) :: :ok | {:error, any}
    +  @callback del_dir(channel_pid :: pid, path :: charlist, timeout) ::
    +              :ok | {:error, any}
    
    -  @callback delete(channel_pid :: pid, path :: charlist, timeout) :: :ok | {:error, any}
    +  @callback delete(channel_pid :: pid, path :: charlist, timeout) ::
    +              :ok | {:error, any}
    
       @callback open(
                   channel_pid :: pid,
    @@ -27,7 +30,12 @@ defmodule SFTPClient.Adapter.SFTP do
                   timeout
                 ) :: {:ok, term} | {:error, any}
    
    -  @callback read(channel_pid :: pid, handle :: term, length :: non_neg_integer, timeout) ::
    +  @callback read(
    +              channel_pid :: pid,
    +              handle :: term,
    +              length :: non_neg_integer,
    +              timeout
    +            ) ::
                   {:ok, binary} | :eof | {:error, any}
    
       @callback readdir(channel_pid :: pid, handle :: term, timeout) ::
    @@ -68,7 +76,12 @@ defmodule SFTPClient.Adapter.SFTP do
                   timeout
                 ) :: :ok | {:error, any}
    
    -  @callback write_file(channel_pid :: pid, path :: charlist, data :: [binary], timeout) ::
    +  @callback write_file(
    +              channel_pid :: pid,
    +              path :: charlist,
    +              data :: [binary],
    +              timeout
    +            ) ::
                   :ok | {:error, any}
    
       @callback write(channel_pid :: pid, path :: charlist, data :: binary, timeout) ::
    diff --git a/lib/sftp_client/operations/connect.ex b/lib/sftp_client/operations/connect.ex
    index a11077e..b3e8749 100644
    --- a/lib/sftp_client/operations/connect.ex
    +++ b/lib/sftp_client/operations/connect.ex
    @@ -61,7 +61,8 @@ defmodule SFTPClient.Operations.Connect do
       @spec connect(
               Config.t() | Keyword.t() | %{optional(atom) => any},
               (Conn.t() -> res)
    -        ) :: {:ok, res} | {:error, any} when res: var
    +        ) :: {:ok, res} | {:error, any}
    +        when res: var
       def connect(config_or_opts, fun) do
         with {:ok, conn} <- connect(config_or_opts) do
           {:ok, run_callback(conn, fun)}
    @@ -86,7 +87,8 @@ defmodule SFTPClient.Operations.Connect do
       @spec connect!(
               Config.t() | Keyword.t() | %{optional(atom) => any},
               (Conn.t() -> res)
    -        ) :: res | no_return when res: var
    +        ) :: res | no_return
    +        when res: var
       def connect!(config_or_opts, fun) do
         config_or_opts
         |> connect!()
    diff --git a/lib/sftp_client/operations/file_info.ex b/lib/sftp_client/operations/file_info.ex
    index 85e7064..7aa39fd 100644
    --- a/lib/sftp_client/operations/file_info.ex
    +++ b/lib/sftp_client/operations/file_info.ex
    @@ -16,7 +16,10 @@ defmodule SFTPClient.Operations.FileInfo do
       @spec file_info(Conn.t(), Path.t()) :: {:ok, FileStat.t()} | {:error, any}
       def file_info(%Conn{} = conn, path) do
         conn.channel_pid
    -    |> sftp_adapter().read_file_info(to_charlist(path), conn.config.operation_timeout)
    +    |> sftp_adapter().read_file_info(
    +      to_charlist(path),
    +      conn.config.operation_timeout
    +    )
         |> case do
           {:ok, file_info} -> {:ok, FileStat.from_record(file_info)}
           {:error, error} -> {:error, handle_error(error)}
    diff --git a/lib/sftp_client/operations/link_info.ex b/lib/sftp_client/operations/link_info.ex
    index 0786161..e094ffa 100644
    --- a/lib/sftp_client/operations/link_info.ex
    +++ b/lib/sftp_client/operations/link_info.ex
    @@ -16,7 +16,10 @@ defmodule SFTPClient.Operations.LinkInfo do
       @spec link_info(Conn.t(), Path.t()) :: {:ok, FileStat.t()} | {:error, any}
       def link_info(%Conn{} = conn, path) do
         conn.channel_pid
    -    |> sftp_adapter().read_link_info(to_charlist(path), conn.config.operation_timeout)
    +    |> sftp_adapter().read_link_info(
    +      to_charlist(path),
    +      conn.config.operation_timeout
    +    )
         |> case do
           {:ok, link_info} -> {:ok, FileStat.from_record(link_info)}
           {:error, error} -> {:error, handle_error(error)}
    diff --git a/lib/sftp_client/operations/open_dir.ex b/lib/sftp_client/operations/open_dir.ex
    index af503c0..0468b81 100644
    --- a/lib/sftp_client/operations/open_dir.ex
    +++ b/lib/sftp_client/operations/open_dir.ex
    @@ -32,7 +32,8 @@ defmodule SFTPClient.Operations.OpenDir do
       finished.
       """
       @spec open_dir(Conn.t(), Path.t(), (Handle.t() -> res)) ::
    -          {:ok, res} | {:error, any} when res: var
    +          {:ok, res} | {:error, any}
    +        when res: var
       def open_dir(%Conn{} = conn, path, fun) do
         with {:ok, handle} = open_dir(conn, path) do
           {:ok, run_callback(handle, fun)}
    @@ -54,7 +55,8 @@ defmodule SFTPClient.Operations.OpenDir do
       finished. Raises when the operation fails.
       """
       @spec open_dir(Conn.t(), Path.t(), (Handle.t() -> res)) ::
    -          res | no_return when res: var
    +          res | no_return
    +        when res: var
       def open_dir!(%Conn{} = conn, path, fun) do
         conn
         |> open_dir!(path)
    diff --git a/lib/sftp_client/operations/open_file.ex b/lib/sftp_client/operations/open_file.ex
    index 4e6017a..6f40d75 100644
    --- a/lib/sftp_client/operations/open_file.ex
    +++ b/lib/sftp_client/operations/open_file.ex
    @@ -17,7 +17,11 @@ defmodule SFTPClient.Operations.OpenFile do
               {:ok, Handle.t()} | {:error, any}
       def open_file(%Conn{} = conn, path, modes) do
         conn.channel_pid
    -    |> sftp_adapter().open(to_charlist(path), modes, conn.config.operation_timeout)
    +    |> sftp_adapter().open(
    +      to_charlist(path),
    +      modes,
    +      conn.config.operation_timeout
    +    )
         |> case do
           {:ok, handle} ->
             {:ok, %Handle{id: handle, conn: conn, path: to_string(path)}}
    @@ -36,7 +40,8 @@ defmodule SFTPClient.Operations.OpenFile do
               Path.t(),
               [SFTPClient.access_mode()],
               (Handle.t() -> res)
    -        ) :: {:ok, res} | {:error, any} when res: var
    +        ) :: {:ok, res} | {:error, any}
    +        when res: var
       def open_file(%Conn{} = conn, path, modes, fun) do
         with {:ok, handle} = open_file(conn, path, modes) do
           {:ok, run_callback(handle, fun)}
    @@ -63,7 +68,8 @@ defmodule SFTPClient.Operations.OpenFile do
               Path.t(),
               [SFTPClient.access_mode()],
               (Handle.t() -> res)
    -        ) :: res | no_return when res: var
    +        ) :: res | no_return
    +        when res: var
       def open_file!(%Conn{} = conn, path, modes, fun) do
         conn
         |> open_file!(path, modes)
    diff --git a/lib/sftp_client/operations/read_file.ex b/lib/sftp_client/operations/read_file.ex
    index a9adbed..0aadb2a 100644
    --- a/lib/sftp_client/operations/read_file.ex
    +++ b/lib/sftp_client/operations/read_file.ex
    @@ -13,7 +13,10 @@ defmodule SFTPClient.Operations.ReadFile do
       @spec read_file(Conn.t(), Path.t()) :: {:ok, binary} | {:error, any}
       def read_file(%Conn{} = conn, path) do
         conn.channel_pid
    -    |> sftp_adapter().read_file(to_charlist(path), conn.config.operation_timeout)
    +    |> sftp_adapter().read_file(
    +      to_charlist(path),
    +      conn.config.operation_timeout
    +    )
         |> case do
           {:ok, content} -> {:ok, content}
           {:error, error} -> {:error, handle_error(error)}
    diff --git a/lib/sftp_client/operations/read_file_chunk.ex b/lib/sftp_client/operations/read_file_chunk.ex
    index deb3534..1205ed5 100644
    --- a/lib/sftp_client/operations/read_file_chunk.ex
    +++ b/lib/sftp_client/operations/read_file_chunk.ex
    @@ -16,7 +16,12 @@ defmodule SFTPClient.Operations.ReadFileChunk do
       @spec read_file_chunk(Handle.t(), non_neg_integer) ::
               {:ok, String.t()} | :eof | {:error, any}
       def read_file_chunk(%Handle{} = handle, length) do
    -    case sftp_adapter().read(handle.conn.channel_pid, handle.id, length, handle.conn.config.operation_timeout) do
    +    case sftp_adapter().read(
    +           handle.conn.channel_pid,
    +           handle.id,
    +           length,
    +           handle.conn.config.operation_timeout
    +         ) do
           {:error, error} -> {:error, handle_error(error)}
           result -> result
         end
    diff --git a/lib/sftp_client/operations/read_link.ex b/lib/sftp_client/operations/read_link.ex
    index 9342b29..5e7e83c 100644
    --- a/lib/sftp_client/operations/read_link.ex
    +++ b/lib/sftp_client/operations/read_link.ex
    @@ -14,7 +14,10 @@ defmodule SFTPClient.Operations.ReadLink do
       @spec read_link(Conn.t(), Path.t()) :: {:ok, Path.t()} | {:error, any}
       def read_link(%Conn{} = conn, path) do
         conn.channel_pid
    -    |> sftp_adapter().read_link(to_charlist(path), conn.config.operation_timeout)
    +    |> sftp_adapter().read_link(
    +      to_charlist(path),
    +      conn.config.operation_timeout
    +    )
         |> case do
           {:ok, target} -> {:ok, to_string(target)}
           {:error, error} -> {:error, handle_error(error)}
    diff --git a/lib/sftp_client/operations/write_file.ex b/lib/sftp_client/operations/write_file.ex
    index 3869803..44e0144 100644
    --- a/lib/sftp_client/operations/write_file.ex
    +++ b/lib/sftp_client/operations/write_file.ex
    @@ -18,7 +18,11 @@ defmodule SFTPClient.Operations.WriteFile do
    
       def write_file(%Conn{} = conn, path, iolist) do
         conn.channel_pid
    -    |> sftp_adapter().write_file(to_charlist(path), Enum.to_list(iolist), conn.config.operation_timeout)
    +    |> sftp_adapter().write_file(
    +      to_charlist(path),
    +      Enum.to_list(iolist),
    +      conn.config.operation_timeout
    +    )
         |> case do
           :ok -> :ok
           {:error, error} -> {:error, handle_error(error)}
    diff --git a/lib/sftp_client/operations/write_file_chunk.ex b/lib/sftp_client/operations/write_file_chunk.ex
    index 2baef96..71a9b1f 100644
    --- a/lib/sftp_client/operations/write_file_chunk.ex
    +++ b/lib/sftp_client/operations/write_file_chunk.ex
    @@ -14,7 +14,12 @@ defmodule SFTPClient.Operations.WriteFileChunk do
       """
       @spec write_file_chunk(Handle.t(), binary) :: :ok | {:error, any}
       def write_file_chunk(%Handle{} = handle, data) do
    -    case sftp_adapter().write(handle.conn.channel_pid, handle.id, data, handle.conn.config.operation_timeout) do
    +    case sftp_adapter().write(
    +           handle.conn.channel_pid,
    +           handle.id,
    +           data,
    +           handle.conn.config.operation_timeout
    +         ) do
           {:error, error} -> {:error, handle_error(error)}
           result -> result
         end
    diff --git a/test/sftp_client/operations/close_handle_test.exs b/test/sftp_client/operations/close_handle_test.exs
    index f443c23..b8c3900 100644
    --- a/test/sftp_client/operations/close_handle_test.exs
    +++ b/test/sftp_client/operations/close_handle_test.exs
    @@ -15,7 +15,9 @@ defmodule SFTPClient.Operations.CloseHandleTest do
    
       describe "close_handle/1" do
         test "success" do
    -      expect(SFTPMock, :close, fn :channel_pid_stub, :handle_id_stub, :infinity ->
    +      expect(SFTPMock, :close, fn :channel_pid_stub,
    +                                  :handle_id_stub,
    +                                  :infinity ->
             :ok
           end)
    
    @@ -25,7 +27,9 @@ defmodule SFTPClient.Operations.CloseHandleTest do
         test "error" do
           reason = :error_stub
    
    -      expect(SFTPMock, :close, fn :channel_pid_stub, :handle_id_stub, :infinity ->
    +      expect(SFTPMock, :close, fn :channel_pid_stub,
    +                                  :handle_id_stub,
    +                                  :infinity ->
             {:error, reason}
           end)
    
    @@ -36,7 +40,9 @@ defmodule SFTPClient.Operations.CloseHandleTest do
    
       describe "close_handle!/1" do
         test "success" do
    -      expect(SFTPMock, :close, fn :channel_pid_stub, :handle_id_stub, :infinity ->
    +      expect(SFTPMock, :close, fn :channel_pid_stub,
    +                                  :handle_id_stub,
    +                                  :infinity ->
             :ok
           end)
    
    @@ -46,7 +52,9 @@ defmodule SFTPClient.Operations.CloseHandleTest do
         test "error" do
           reason = :error_stub
    
    -      expect(SFTPMock, :close, fn :channel_pid_stub, :handle_id_stub, :infinity ->
    +      expect(SFTPMock, :close, fn :channel_pid_stub,
    +                                  :handle_id_stub,
    +                                  :infinity ->
             {:error, reason}
           end)
    
    diff --git a/test/sftp_client/operations/delete_dir_test.exs b/test/sftp_client/operations/delete_dir_test.exs
    index 4a94e77..30988c8 100644
    --- a/test/sftp_client/operations/delete_dir_test.exs
    +++ b/test/sftp_client/operations/delete_dir_test.exs
    @@ -14,7 +14,9 @@ defmodule SFTPClient.Operations.DeleteDirTest do
    
       describe "delete_dir/2" do
         test "success" do
    -      expect(SFTPMock, :del_dir, fn :channel_pid_stub, 'my/test/path', :infinity ->
    +      expect(SFTPMock, :del_dir, fn :channel_pid_stub,
    +                                    'my/test/path',
    +                                    :infinity ->
             :ok
           end)
    
    @@ -24,7 +26,9 @@ defmodule SFTPClient.Operations.DeleteDirTest do
         test "error" do
           reason = :error_stub
    
    -      expect(SFTPMock, :del_dir, fn :channel_pid_stub, 'my/test/path', :infinity ->
    +      expect(SFTPMock, :del_dir, fn :channel_pid_stub,
    +                                    'my/test/path',
    +                                    :infinity ->
             {:error, reason}
           end)
    
    @@ -35,7 +39,9 @@ defmodule SFTPClient.Operations.DeleteDirTest do
    
       describe "delete_dir!/2" do
         test "success" do
    -      expect(SFTPMock, :del_dir, fn :channel_pid_stub, 'my/test/path', :infinity ->
    +      expect(SFTPMock, :del_dir, fn :channel_pid_stub,
    +                                    'my/test/path',
    +                                    :infinity ->
             :ok
           end)
    
    @@ -45,7 +51,9 @@ defmodule SFTPClient.Operations.DeleteDirTest do
         test "error" do
           reason = :error_stub
    
    -      expect(SFTPMock, :del_dir, fn :channel_pid_stub, 'my/test/path', :infinity ->
    +      expect(SFTPMock, :del_dir, fn :channel_pid_stub,
    +                                    'my/test/path',
    +                                    :infinity ->
             {:error, reason}
           end)
    
    diff --git a/test/sftp_client/operations/delete_file_test.exs b/test/sftp_client/operations/delete_file_test.exs
    index 64ad2f4..9c06eca 100644
    --- a/test/sftp_client/operations/delete_file_test.exs
    +++ b/test/sftp_client/operations/delete_file_test.exs
    @@ -14,7 +14,9 @@ defmodule SFTPClient.Operations.DeleteFileTest do
    
       describe "delete_file/2" do
         test "success" do
    -      expect(SFTPMock, :delete, fn :channel_pid_stub, 'my/test/path', :infinity ->
    +      expect(SFTPMock, :delete, fn :channel_pid_stub,
    +                                   'my/test/path',
    +                                   :infinity ->
             :ok
           end)
    
    @@ -24,7 +26,9 @@ defmodule SFTPClient.Operations.DeleteFileTest do
         test "error" do
           reason = :error_stub
    
    -      expect(SFTPMock, :delete, fn :channel_pid_stub, 'my/test/path', :infinity ->
    +      expect(SFTPMock, :delete, fn :channel_pid_stub,
    +                                   'my/test/path',
    +                                   :infinity ->
             {:error, reason}
           end)
    
    @@ -35,7 +39,9 @@ defmodule SFTPClient.Operations.DeleteFileTest do
    
       describe "delete_file!/2" do
         test "success" do
    -      expect(SFTPMock, :delete, fn :channel_pid_stub, 'my/test/path', :infinity ->
    +      expect(SFTPMock, :delete, fn :channel_pid_stub,
    +                                   'my/test/path',
    +                                   :infinity ->
             :ok
           end)
    
    @@ -45,7 +51,9 @@ defmodule SFTPClient.Operations.DeleteFileTest do
         test "error" do
           reason = :error_stub
    
    -      expect(SFTPMock, :delete, fn :channel_pid_stub, 'my/test/path', :infinity ->
    +      expect(SFTPMock, :delete, fn :channel_pid_stub,
    +                                   'my/test/path',
    +                                   :infinity ->
             {:error, reason}
           end)
    
    diff --git a/test/sftp_client/operations/download_file_test.exs b/test/sftp_client/operations/download_file_test.exs
    index aed81d1..018a21d 100644
    --- a/test/sftp_client/operations/download_file_test.exs
    +++ b/test/sftp_client/operations/download_file_test.exs
    @@ -5,7 +5,6 @@ defmodule SFTPClient.Operations.DownloadFileTest do
       import SFTPClient.ConnHelper
    
       alias SFTPClient.Adapter.SFTP.Mock, as: SFTPMock
    -  alias SFTPClient.Conn
       alias SFTPClient.ConnError
       alias SFTPClient.OperationError
       alias SFTPClient.Operations.DownloadFile
    @@ -35,8 +34,12 @@ defmodule SFTPClient.Operations.DownloadFileTest do
           |> expect(:read, fn :channel_pid_stub, :handle_id_stub, _, :infinity ->
             {:ok, file_content}
           end)
    -      |> expect(:read, fn :channel_pid_stub, :handle_id_stub, _, :infinity -> :eof end)
    -      |> expect(:close, fn :channel_pid_stub, :handle_id_stub, :infinity -> :ok end)
    +      |> expect(:read, fn :channel_pid_stub, :handle_id_stub, _, :infinity ->
    +        :eof
    +      end)
    +      |> expect(:close, fn :channel_pid_stub, :handle_id_stub, :infinity ->
    +        :ok
    +      end)
    
           assert DownloadFile.download_file(@conn, "my/remote/path", local_path) ==
                    {:ok, local_path}
    @@ -58,8 +61,12 @@ defmodule SFTPClient.Operations.DownloadFileTest do
           |> expect(:read, fn :channel_pid_stub, :handle_id_stub, _, :infinity ->
             {:ok, file_content}
           end)
    -      |> expect(:read, fn :channel_pid_stub, :handle_id_stub, _, :infinity -> :eof end)
    -      |> expect(:close, fn :channel_pid_stub, :handle_id_stub, :infinity -> :ok end)
    +      |> expect(:read, fn :channel_pid_stub, :handle_id_stub, _, :infinity ->
    +        :eof
    +      end)
    +      |> expect(:close, fn :channel_pid_stub, :handle_id_stub, :infinity ->
    +        :ok
    +      end)
    
           assert DownloadFile.download_file(
                    @conn,
    @@ -128,8 +135,12 @@ defmodule SFTPClient.Operations.DownloadFileTest do
           |> expect(:read, fn :channel_pid_stub, :handle_id_stub, _, :infinity ->
             {:ok, file_content}
           end)
    -      |> expect(:read, fn :channel_pid_stub, :handle_id_stub, _, :infinity -> :eof end)
    -      |> expect(:close, fn :channel_pid_stub, :handle_id_stub, :infinity -> :ok end)
    +      |> expect(:read, fn :channel_pid_stub, :handle_id_stub, _, :infinity ->
    +        :eof
    +      end)
    +      |> expect(:close, fn :channel_pid_stub, :handle_id_stub, :infinity ->
    +        :ok
    +      end)
    
           assert DownloadFile.download_file!(@conn, "my/remote/path", local_path) ==
                    local_path
    diff --git a/test/sftp_client/operations/file_info_test.exs b/test/sftp_client/operations/file_info_test.exs
    index eeee1f8..ad20fb9 100644
    --- a/test/sftp_client/operations/file_info_test.exs
    +++ b/test/sftp_client/operations/file_info_test.exs
    @@ -6,7 +6,6 @@ defmodule SFTPClient.Operations.FileInfoTest do
    
       alias File.Stat, as: FileStat
       alias SFTPClient.Adapter.SFTP.Mock, as: SFTPMock
    -  alias SFTPClient.Conn
       alias SFTPClient.OperationError
       alias SFTPClient.Operations.FileInfo
    
    diff --git a/test/sftp_client/operations/link_info_test.exs b/test/sftp_client/operations/link_info_test.exs
    index 72bc2f0..0af1d1b 100644
    --- a/test/sftp_client/operations/link_info_test.exs
    +++ b/test/sftp_client/operations/link_info_test.exs
    @@ -6,7 +6,6 @@ defmodule SFTPClient.Operations.LinkInfoTest do
    
       alias File.Stat, as: FileStat
       alias SFTPClient.Adapter.SFTP.Mock, as: SFTPMock
    -  alias SFTPClient.Conn
       alias SFTPClient.OperationError
       alias SFTPClient.Operations.LinkInfo
    
    diff --git a/test/sftp_client/operations/list_dir_test.exs b/test/sftp_client/operations/list_dir_test.exs
    index 20d38ac..6a726b5 100644
    --- a/test/sftp_client/operations/list_dir_test.exs
    +++ b/test/sftp_client/operations/list_dir_test.exs
    @@ -5,7 +5,6 @@ defmodule SFTPClient.Operations.ListDirTest do
       import SFTPClient.ConnHelper
    
       alias SFTPClient.Adapter.SFTP.Mock, as: SFTPMock
    -  alias SFTPClient.Conn
       alias SFTPClient.OperationError
       alias SFTPClient.Operations.ListDir
    
    @@ -15,7 +14,9 @@ defmodule SFTPClient.Operations.ListDirTest do
    
       describe "list_dir/2" do
         test "success" do
    -      expect(SFTPMock, :list_dir, fn :channel_pid_stub, 'my/remote/path', :infinity ->
    +      expect(SFTPMock, :list_dir, fn :channel_pid_stub,
    +                                     'my/remote/path',
    +                                     :infinity ->
             {:ok,
              [
                '..',
    @@ -38,7 +39,9 @@ defmodule SFTPClient.Operations.ListDirTest do
         test "error" do
           reason = :enoent
    
    -      expect(SFTPMock, :list_dir, fn :channel_pid_stub, 'my/remote/path', :infinity ->
    +      expect(SFTPMock, :list_dir, fn :channel_pid_stub,
    +                                     'my/remote/path',
    +                                     :infinity ->
             {:error, reason}
           end)
    
    @@ -49,7 +52,9 @@ defmodule SFTPClient.Operations.ListDirTest do
    
       describe "list_dir!/2" do
         test "success" do
    -      expect(SFTPMock, :list_dir, fn :channel_pid_stub, 'my/remote/path', :infinity ->
    +      expect(SFTPMock, :list_dir, fn :channel_pid_stub,
    +                                     'my/remote/path',
    +                                     :infinity ->
             {:ok,
              [
                '..',
    @@ -71,7 +76,9 @@ defmodule SFTPClient.Operations.ListDirTest do
         test "error" do
           reason = :enoent
    
    -      expect(SFTPMock, :list_dir, fn :channel_pid_stub, 'my/remote/path', :infinity ->
    +      expect(SFTPMock, :list_dir, fn :channel_pid_stub,
    +                                     'my/remote/path',
    +                                     :infinity ->
             {:error, reason}
           end)
    
    diff --git a/test/sftp_client/operations/make_dir_test.exs b/test/sftp_client/operations/make_dir_test.exs
    index fe164f0..0b15114 100644
    --- a/test/sftp_client/operations/make_dir_test.exs
    +++ b/test/sftp_client/operations/make_dir_test.exs
    @@ -5,7 +5,6 @@ defmodule SFTPClient.Operations.MakeDirTest do
       import SFTPClient.ConnHelper
    
       alias SFTPClient.Adapter.SFTP.Mock, as: SFTPMock
    -  alias SFTPClient.Conn
       alias SFTPClient.OperationError
       alias SFTPClient.Operations.MakeDir
    
    @@ -15,7 +14,9 @@ defmodule SFTPClient.Operations.MakeDirTest do
    
       describe "make_dir/2" do
         test "success" do
    -      expect(SFTPMock, :make_dir, fn :channel_pid_stub, 'my/test/path', :infinity ->
    +      expect(SFTPMock, :make_dir, fn :channel_pid_stub,
    +                                     'my/test/path',
    +                                     :infinity ->
             :ok
           end)
    
    @@ -25,7 +26,9 @@ defmodule SFTPClient.Operations.MakeDirTest do
         test "error" do
           reason = :error_stub
    
    -      expect(SFTPMock, :make_dir, fn :channel_pid_stub, 'my/test/path', :infinity ->
    +      expect(SFTPMock, :make_dir, fn :channel_pid_stub,
    +                                     'my/test/path',
    +                                     :infinity ->
             {:error, reason}
           end)
    
    @@ -36,7 +39,9 @@ defmodule SFTPClient.Operations.MakeDirTest do
    
       describe "make_dir!/2" do
         test "success" do
    -      expect(SFTPMock, :make_dir, fn :channel_pid_stub, 'my/test/path', :infinity ->
    +      expect(SFTPMock, :make_dir, fn :channel_pid_stub,
    +                                     'my/test/path',
    +                                     :infinity ->
             :ok
           end)
    
    @@ -46,7 +51,9 @@ defmodule SFTPClient.Operations.MakeDirTest do
         test "error" do
           reason = :error_stub
    
    -      expect(SFTPMock, :make_dir, fn :channel_pid_stub, 'my/test/path', :infinity ->
    +      expect(SFTPMock, :make_dir, fn :channel_pid_stub,
    +                                     'my/test/path',
    +                                     :infinity ->
             {:error, reason}
           end)
    
    diff --git a/test/sftp_client/operations/make_link_test.exs b/test/sftp_client/operations/make_link_test.exs
    index ab5fe84..5c7f7e8 100644
    --- a/test/sftp_client/operations/make_link_test.exs
    +++ b/test/sftp_client/operations/make_link_test.exs
    @@ -5,7 +5,6 @@ defmodule SFTPClient.Operations.MakeLinkTest do
       import SFTPClient.ConnHelper
    
       alias SFTPClient.Adapter.SFTP.Mock, as: SFTPMock
    -  alias SFTPClient.Conn
       alias SFTPClient.OperationError
       alias SFTPClient.Operations.MakeLink
    
    diff --git a/test/sftp_client/operations/open_dir_test.exs b/test/sftp_client/operations/open_dir_test.exs
    index 6fa985d..df14642 100644
    --- a/test/sftp_client/operations/open_dir_test.exs
    +++ b/test/sftp_client/operations/open_dir_test.exs
    @@ -5,7 +5,6 @@ defmodule SFTPClient.Operations.OpenDirTest do
       import SFTPClient.ConnHelper
    
       alias SFTPClient.Adapter.SFTP.Mock, as: SFTPMock
    -  alias SFTPClient.Conn
       alias SFTPClient.Handle
       alias SFTPClient.OperationError
       alias SFTPClient.Operations.OpenDir
    @@ -17,7 +16,9 @@ defmodule SFTPClient.Operations.OpenDirTest do
    
       describe "open_dir/2" do
         test "success" do
    -      expect(SFTPMock, :opendir, fn :channel_pid_stub, 'my/remote/path', :infinity ->
    +      expect(SFTPMock, :opendir, fn :channel_pid_stub,
    +                                    'my/remote/path',
    +                                    :infinity ->
             {:ok, :handle_id_stub}
           end)
    
    @@ -28,7 +29,9 @@ defmodule SFTPClient.Operations.OpenDirTest do
         test "error" do
           reason = :enoent
    
    -      expect(SFTPMock, :opendir, fn :channel_pid_stub, 'my/remote/path', :infinity ->
    +      expect(SFTPMock, :opendir, fn :channel_pid_stub,
    +                                    'my/remote/path',
    +                                    :infinity ->
             {:error, reason}
           end)
    
    @@ -45,7 +48,9 @@ defmodule SFTPClient.Operations.OpenDirTest do
    
       describe "open_dir!/2" do
         test "success" do
    -      expect(SFTPMock, :opendir, fn :channel_pid_stub, 'my/remote/path', :infinity ->
    +      expect(SFTPMock, :opendir, fn :channel_pid_stub,
    +                                    'my/remote/path',
    +                                    :infinity ->
             {:ok, :handle_id_stub}
           end)
    
    @@ -56,7 +61,9 @@ defmodule SFTPClient.Operations.OpenDirTest do
         test "error" do
           reason = :enoent
    
    -      expect(SFTPMock, :opendir, fn :channel_pid_stub, 'my/remote/path', :infinity ->
    +      expect(SFTPMock, :opendir, fn :channel_pid_stub,
    +                                    'my/remote/path',
    +                                    :infinity ->
             {:error, reason}
           end)
    
    diff --git a/test/sftp_client/operations/open_file_test.exs b/test/sftp_client/operations/open_file_test.exs
    index d9e4daf..00d94c5 100644
    --- a/test/sftp_client/operations/open_file_test.exs
    +++ b/test/sftp_client/operations/open_file_test.exs
    @@ -1,27 +1,27 @@
    -defmodule SFTPClient.Operations.OpenFileTest do
    -  use ExUnit.Case, async: true
    -
    -  describe "open_file/3" do
    -    test "success"
    -
    -    test "error"
    -  end
    -
    -  describe "open_file/4" do
    -    test "success"
    -
    -    test "error"
    -  end
    -
    -  describe "open_file!/3" do
    -    test "success"
    -
    -    test "error"
    -  end
    -
    -  describe "open_file!/4" do
    -    test "success"
    -
    -    test "error"
    -  end
    -end
    +defmodule SFTPClient.Operations.OpenFileTest do
    +  use ExUnit.Case, async: true
    +
    +  describe "open_file/3" do
    +    test "success"
    +
    +    test "error"
    +  end
    +
    +  describe "open_file/4" do
    +    test "success"
    +
    +    test "error"
    +  end
    +
    +  describe "open_file!/3" do
    +    test "success"
    +
    +    test "error"
    +  end
    +
    +  describe "open_file!/4" do
    +    test "success"
    +
    +    test "error"
    +  end
    +end
    diff --git a/test/sftp_client/operations/read_dir_test.exs b/test/sftp_client/operations/read_dir_test.exs
    index 933a84e..eee8924 100644
    --- a/test/sftp_client/operations/read_dir_test.exs
    +++ b/test/sftp_client/operations/read_dir_test.exs
    @@ -5,7 +5,6 @@ defmodule SFTPClient.Operations.ReadDirTest do
       import SFTPClient.ConnHelper
    
       alias SFTPClient.Adapter.SFTP.Mock, as: SFTPMock
    -  alias SFTPClient.Conn
       alias SFTPClient.Entry
       alias SFTPClient.Handle
       alias SFTPClient.OperationError
    @@ -50,7 +49,9 @@ defmodule SFTPClient.Operations.ReadDirTest do
    
       describe "read_dir/1" do
         test "success", %{decoded_entries: decoded_entries} do
    -      expect(SFTPMock, :readdir, fn :channel_pid_stub, :handle_id_stub, :infinity ->
    +      expect(SFTPMock, :readdir, fn :channel_pid_stub,
    +                                    :handle_id_stub,
    +                                    :infinity ->
             {:ok, @encoded_entries}
           end)
    
    @@ -60,7 +61,9 @@ defmodule SFTPClient.Operations.ReadDirTest do
         test "error" do
           reason = :enoent
    
    -      expect(SFTPMock, :readdir, fn :channel_pid_stub, :handle_id_stub, :infinity ->
    +      expect(SFTPMock, :readdir, fn :channel_pid_stub,
    +                                    :handle_id_stub,
    +                                    :infinity ->
             {:error, reason}
           end)
    
    @@ -71,7 +74,9 @@ defmodule SFTPClient.Operations.ReadDirTest do
    
       describe "read_dir!/1" do
         test "success", %{decoded_entries: decoded_entries} do
    -      expect(SFTPMock, :readdir, fn :channel_pid_stub, :handle_id_stub, :infinity ->
    +      expect(SFTPMock, :readdir, fn :channel_pid_stub,
    +                                    :handle_id_stub,
    +                                    :infinity ->
             {:ok, @encoded_entries}
           end)
    
    @@ -81,7 +86,9 @@ defmodule SFTPClient.Operations.ReadDirTest do
         test "error" do
           reason = :enoent
    
    -      expect(SFTPMock, :readdir, fn :channel_pid_stub, :handle_id_stub, :infinity ->
    +      expect(SFTPMock, :readdir, fn :channel_pid_stub,
    +                                    :handle_id_stub,
    +                                    :infinity ->
             {:error, reason}
           end)
    
    diff --git a/test/sftp_client/operations/read_file_chunk_test.exs b/test/sftp_client/operations/read_file_chunk_test.exs
    index 258ce82..d3d049b 100644
    --- a/test/sftp_client/operations/read_file_chunk_test.exs
    +++ b/test/sftp_client/operations/read_file_chunk_test.exs
    @@ -5,7 +5,6 @@ defmodule SFTPClient.Operations.ReadFileChunkTest do
       import SFTPClient.ConnHelper
    
       alias SFTPClient.Adapter.SFTP.Mock, as: SFTPMock
    -  alias SFTPClient.Conn
       alias SFTPClient.Handle
       alias SFTPClient.OperationError
       alias SFTPClient.Operations.ReadFileChunk
    diff --git a/test/sftp_client/operations/read_file_test.exs b/test/sftp_client/operations/read_file_test.exs
    index 137bfa9..e7b16be 100644
    --- a/test/sftp_client/operations/read_file_test.exs
    +++ b/test/sftp_client/operations/read_file_test.exs
    @@ -5,7 +5,6 @@ defmodule SFTPClient.Operations.ReadFileTest do
       import SFTPClient.ConnHelper
    
       alias SFTPClient.Adapter.SFTP.Mock, as: SFTPMock
    -  alias SFTPClient.Conn
       alias SFTPClient.OperationError
       alias SFTPClient.Operations.ReadFile
    
    @@ -17,7 +16,9 @@ defmodule SFTPClient.Operations.ReadFileTest do
         test "success" do
           file_content = "file content stub"
    
    -      expect(SFTPMock, :read_file, fn :channel_pid_stub, 'my/remote/path', :infinity ->
    +      expect(SFTPMock, :read_file, fn :channel_pid_stub,
    +                                      'my/remote/path',
    +                                      :infinity ->
             {:ok, file_content}
           end)
    
    @@ -27,7 +28,9 @@ defmodule SFTPClient.Operations.ReadFileTest do
         test "error" do
           reason = :enoent
    
    -      expect(SFTPMock, :read_file, fn :channel_pid_stub, 'my/remote/path', :infinity ->
    +      expect(SFTPMock, :read_file, fn :channel_pid_stub,
    +                                      'my/remote/path',
    +                                      :infinity ->
             {:error, reason}
           end)
    
    @@ -40,7 +43,9 @@ defmodule SFTPClient.Operations.ReadFileTest do
         test "success" do
           file_content = "file content stub"
    
    -      expect(SFTPMock, :read_file, fn :channel_pid_stub, 'my/remote/path', :infinity ->
    +      expect(SFTPMock, :read_file, fn :channel_pid_stub,
    +                                      'my/remote/path',
    +                                      :infinity ->
             {:ok, file_content}
           end)
    
    @@ -50,7 +55,9 @@ defmodule SFTPClient.Operations.ReadFileTest do
         test "error" do
           reason = :enoent
    
    -      expect(SFTPMock, :read_file, fn :channel_pid_stub, 'my/remote/path', :infinity ->
    +      expect(SFTPMock, :read_file, fn :channel_pid_stub,
    +                                      'my/remote/path',
    +                                      :infinity ->
             {:error, reason}
           end)
    
    diff --git a/test/sftp_client/operations/read_link_test.exs b/test/sftp_client/operations/read_link_test.exs
    index 726e4fa..ba5113c 100644
    --- a/test/sftp_client/operations/read_link_test.exs
    +++ b/test/sftp_client/operations/read_link_test.exs
    @@ -5,7 +5,6 @@ defmodule SFTPClient.Operations.ReadLinkTest do
       import SFTPClient.ConnHelper
    
       alias SFTPClient.Adapter.SFTP.Mock, as: SFTPMock
    -  alias SFTPClient.Conn
       alias SFTPClient.OperationError
       alias SFTPClient.Operations.ReadLink
    
    @@ -15,7 +14,9 @@ defmodule SFTPClient.Operations.ReadLinkTest do
    
       describe "read_link/2" do
         test "success" do
    -      expect(SFTPMock, :read_link, fn :channel_pid_stub, 'my/remote/path', :infinity ->
    +      expect(SFTPMock, :read_link, fn :channel_pid_stub,
    +                                      'my/remote/path',
    +                                      :infinity ->
             {:ok, 'my/path/to/real/file'}
           end)
    
    @@ -26,7 +27,9 @@ defmodule SFTPClient.Operations.ReadLinkTest do
         test "error" do
           reason = :enoent
    
    -      expect(SFTPMock, :read_link, fn :channel_pid_stub, 'my/remote/path', :infinity ->
    +      expect(SFTPMock, :read_link, fn :channel_pid_stub,
    +                                      'my/remote/path',
    +                                      :infinity ->
             {:error, reason}
           end)
    
    @@ -37,7 +40,9 @@ defmodule SFTPClient.Operations.ReadLinkTest do
    
       describe "read_link!/2" do
         test "success" do
    -      expect(SFTPMock, :read_link, fn :channel_pid_stub, 'my/remote/path', :infinity ->
    +      expect(SFTPMock, :read_link, fn :channel_pid_stub,
    +                                      'my/remote/path',
    +                                      :infinity ->
             {:ok, 'my/path/to/real/file'}
           end)
    
    @@ -48,7 +53,9 @@ defmodule SFTPClient.Operations.ReadLinkTest do
         test "error" do
           reason = :enoent
    
    -      expect(SFTPMock, :read_link, fn :channel_pid_stub, 'my/remote/path', :infinity ->
    +      expect(SFTPMock, :read_link, fn :channel_pid_stub,
    +                                      'my/remote/path',
    +                                      :infinity ->
             {:error, reason}
           end)
    
    diff --git a/test/sftp_client/operations/rename_test.exs b/test/sftp_client/operations/rename_test.exs
    index d5f6d2e..ab4c1b2 100644
    --- a/test/sftp_client/operations/rename_test.exs
    +++ b/test/sftp_client/operations/rename_test.exs
    @@ -5,7 +5,6 @@ defmodule SFTPClient.Operations.RenameTest do
       import SFTPClient.ConnHelper
    
       alias SFTPClient.Adapter.SFTP.Mock, as: SFTPMock
    -  alias SFTPClient.Conn
       alias SFTPClient.OperationError
       alias SFTPClient.Operations.Rename
    
    diff --git a/test/sftp_client/operations/stream_file_test.exs b/test/sftp_client/operations/stream_file_test.exs
    index e7c8b06..b4b3e94 100644
    --- a/test/sftp_client/operations/stream_file_test.exs
    +++ b/test/sftp_client/operations/stream_file_test.exs
    @@ -6,7 +6,6 @@ defmodule SFTPClient.Operations.StreamFileTest do
    
       alias File.Stat, as: FileStat
       alias SFTPClient.Adapter.SFTP.Mock, as: SFTPMock
    -  alias SFTPClient.Conn
       alias SFTPClient.OperationError
       alias SFTPClient.Operations.StreamFile
       alias SFTPClient.Stream, as: SFTPStream
    diff --git a/test/sftp_client/operations/upload_file_test.exs b/test/sftp_client/operations/upload_file_test.exs
    index f98d90d..15f74ed 100644
    --- a/test/sftp_client/operations/upload_file_test.exs
    +++ b/test/sftp_client/operations/upload_file_test.exs
    @@ -5,7 +5,6 @@ defmodule SFTPClient.Operations.UploadFileTest do
       import SFTPClient.ConnHelper
    
       alias SFTPClient.Adapter.SFTP.Mock, as: SFTPMock
    -  alias SFTPClient.Conn
       alias SFTPClient.ConnError
       alias SFTPClient.OperationError
       alias SFTPClient.Operations.UploadFile
    @@ -28,16 +27,27 @@ defmodule SFTPClient.Operations.UploadFileTest do
                               :infinity ->
             {:ok, :handle_id_stub}
           end)
    -      |> expect(:write, fn :channel_pid_stub, :handle_id_stub, ^line_a ->
    +      |> expect(:write, fn :channel_pid_stub,
    +                           :handle_id_stub,
    +                           ^line_a,
    +                           :infinity ->
             :ok
           end)
    -      |> expect(:write, fn :channel_pid_stub, :handle_id_stub, ^line_b ->
    +      |> expect(:write, fn :channel_pid_stub,
    +                           :handle_id_stub,
    +                           ^line_b,
    +                           :infinity ->
             :ok
           end)
    -      |> expect(:write, fn :channel_pid_stub, :handle_id_stub, ^line_c ->
    +      |> expect(:write, fn :channel_pid_stub,
    +                           :handle_id_stub,
    +                           ^line_c,
    +                           :infinity ->
    +        :ok
    +      end)
    +      |> expect(:close, fn :channel_pid_stub, :handle_id_stub, :infinity ->
             :ok
           end)
    -      |> expect(:close, fn :channel_pid_stub, :handle_id_stub -> :ok end)
    
           assert UploadFile.upload_file(@conn, @local_path, @remote_path) ==
                    {:ok, @remote_path}
    @@ -48,7 +58,8 @@ defmodule SFTPClient.Operations.UploadFileTest do
    
           expect(SFTPMock, :open, fn :channel_pid_stub,
                                      'my/remote/file.txt',
    -                                 [:write, :creat, :binary] ->
    +                                 [:write, :creat, :binary],
    +                                 :infinity ->
             {:error, message}
           end)
    
    @@ -61,7 +72,8 @@ defmodule SFTPClient.Operations.UploadFileTest do
    
           expect(SFTPMock, :open, fn :channel_pid_stub,
                                      'my/remote/file.txt',
    -                                 [:write, :creat, :binary] ->
    +                                 [:write, :creat, :binary],
    +                                 :infinity ->
             {:error, reason}
           end)
    
    @@ -74,7 +86,8 @@ defmodule SFTPClient.Operations.UploadFileTest do
    
           expect(SFTPMock, :open, fn :channel_pid_stub,
                                      'my/remote/file.txt',
    -                                 [:write, :creat, :binary] ->
    +                                 [:write, :creat, :binary],
    +                                 :infinity ->
             raise RuntimeError, message
           end)
    
    @@ -92,19 +105,31 @@ defmodule SFTPClient.Operations.UploadFileTest do
           SFTPMock
           |> expect(:open, fn :channel_pid_stub,
                               'my/remote/file.txt',
    -                          [:write, :creat, :binary] ->
    +                          [:write, :creat, :binary],
    +                          :infinity ->
             {:ok, :handle_id_stub}
           end)
    -      |> expect(:write, fn :channel_pid_stub, :handle_id_stub, ^line_a ->
    +      |> expect(:write, fn :channel_pid_stub,
    +                           :handle_id_stub,
    +                           ^line_a,
    +                           :infinity ->
    +        :ok
    +      end)
    +      |> expect(:write, fn :channel_pid_stub,
    +                           :handle_id_stub,
    +                           ^line_b,
    +                           :infinity ->
             :ok
           end)
    -      |> expect(:write, fn :channel_pid_stub, :handle_id_stub, ^line_b ->
    +      |> expect(:write, fn :channel_pid_stub,
    +                           :handle_id_stub,
    +                           ^line_c,
    +                           :infinity ->
             :ok
           end)
    -      |> expect(:write, fn :channel_pid_stub, :handle_id_stub, ^line_c ->
    +      |> expect(:close, fn :channel_pid_stub, :handle_id_stub, :infinity ->
             :ok
           end)
    -      |> expect(:close, fn :channel_pid_stub, :handle_id_stub -> :ok end)
    
           assert UploadFile.upload_file!(@conn, @local_path, @remote_path) ==
                    @remote_path
    @@ -115,7 +140,8 @@ defmodule SFTPClient.Operations.UploadFileTest do
    
           expect(SFTPMock, :open, fn :channel_pid_stub,
                                      'my/remote/file.txt',
    -                                 [:write, :creat, :binary] ->
    +                                 [:write, :creat, :binary],
    +                                 :infinity ->
             {:error, message}
           end)
    
    @@ -129,7 +155,8 @@ defmodule SFTPClient.Operations.UploadFileTest do
    
           expect(SFTPMock, :open, fn :channel_pid_stub,
                                      'my/remote/file.txt',
    -                                 [:write, :creat, :binary] ->
    +                                 [:write, :creat, :binary],
    +                                 :infinity ->
             {:error, reason}
           end)
    
    @@ -143,7 +170,8 @@ defmodule SFTPClient.Operations.UploadFileTest do
    
           expect(SFTPMock, :open, fn :channel_pid_stub,
                                      'my/remote/file.txt',
    -                                 [:write, :creat, :binary] ->
    +                                 [:write, :creat, :binary],
    +                                 :infinity ->
             raise RuntimeError, message
           end)
    
    diff --git a/test/sftp_client/operations/write_file_chunk_test.exs b/test/sftp_client/operations/write_file_chunk_test.exs
    index 5e2c068..d098d95 100644
    --- a/test/sftp_client/operations/write_file_chunk_test.exs
    +++ b/test/sftp_client/operations/write_file_chunk_test.exs
    @@ -5,7 +5,6 @@ defmodule SFTPClient.Operations.WriteFileChunkTest do
       import SFTPClient.ConnHelper
    
       alias SFTPClient.Adapter.SFTP.Mock, as: SFTPMock
    -  alias SFTPClient.Conn
       alias SFTPClient.Handle
       alias SFTPClient.OperationError
       alias SFTPClient.Operations.WriteFileChunk
    @@ -19,7 +18,10 @@ defmodule SFTPClient.Operations.WriteFileChunkTest do
         test "success" do
           chunk_content = "chunk stub"
    
    -      expect(SFTPMock, :write, fn :channel_pid_stub, :handle_id_stub, @data ->
    +      expect(SFTPMock, :write, fn :channel_pid_stub,
    +                                  :handle_id_stub,
    +                                  @data,
    +                                  :infinity ->
             {:ok, chunk_content}
           end)
    
    @@ -30,7 +32,10 @@ defmodule SFTPClient.Operations.WriteFileChunkTest do
         test "error" do
           reason = :enoent
    
    -      expect(SFTPMock, :write, fn :channel_pid_stub, :handle_id_stub, @data ->
    +      expect(SFTPMock, :write, fn :channel_pid_stub,
    +                                  :handle_id_stub,
    +                                  @data,
    +                                  :infinity ->
             {:error, reason}
           end)
    
    @@ -43,7 +48,10 @@ defmodule SFTPClient.Operations.WriteFileChunkTest do
         test "success" do
           chunk_content = "chunk stub"
    
    -      expect(SFTPMock, :write, fn :channel_pid_stub, :handle_id_stub, @data ->
    +      expect(SFTPMock, :write, fn :channel_pid_stub,
    +                                  :handle_id_stub,
    +                                  @data,
    +                                  :infinity ->
             {:ok, chunk_content}
           end)
    
    @@ -54,7 +62,10 @@ defmodule SFTPClient.Operations.WriteFileChunkTest do
         test "error" do
           reason = :enoent
    
    -      expect(SFTPMock, :write, fn :channel_pid_stub, :handle_id_stub, @data ->
    +      expect(SFTPMock, :write, fn :channel_pid_stub,
    +                                  :handle_id_stub,
    +                                  @data,
    +                                  :infinity ->
             {:error, reason}
           end)
    
    diff --git a/test/sftp_client/operations/write_file_test.exs b/test/sftp_client/operations/write_file_test.exs
    index e817f86..49084c1 100644
    --- a/test/sftp_client/operations/write_file_test.exs
    +++ b/test/sftp_client/operations/write_file_test.exs
    @@ -5,7 +5,6 @@ defmodule SFTPClient.Operations.WriteFileTest do
       import SFTPClient.ConnHelper
    
       alias SFTPClient.Adapter.SFTP.Mock, as: SFTPMock
    -  alias SFTPClient.Conn
       alias SFTPClient.OperationError
       alias SFTPClient.Operations.WriteFile
    
    diff --git a/test/sftp_client/stream_test.exs b/test/sftp_client/stream_test.exs
    index ac0691c..f25acd2 100644
    --- a/test/sftp_client/stream_test.exs
    +++ b/test/sftp_client/stream_test.exs
    @@ -3,16 +3,16 @@ defmodule SFTPClient.StreamTest do
    
       import ExUnit.CaptureLog
       import Mox
    +  import SFTPClient.ConnHelper
    
       alias SFTPClient.Adapter.SFTP.Mock, as: SFTPMock
    -  alias SFTPClient.Conn
       alias SFTPClient.OperationError
       alias SFTPClient.Stream, as: SFTPStream
    
       setup :verify_on_exit!
    
       @stream %SFTPStream{
    -    conn: %Conn{channel_pid: :channel_pid_stub},
    +    conn: build_conn(),
         path: "my/remote/path",
         chunk_size: 1337
       }
    @@ -39,13 +39,16 @@ defmodule SFTPClient.StreamTest do
           SFTPMock
           |> expect(:open, fn :channel_pid_stub,
                               'my/remote/path',
    -                          [:read, :binary] ->
    +                          [:read, :binary],
    +                          _ ->
             {:ok, :handle_id_stub}
           end)
    -      |> expect(:read, fn :channel_pid_stub, :handle_id_stub, 1337 ->
    +      |> expect(:read, fn :channel_pid_stub, :handle_id_stub, 1337, _ ->
             {:error, :enoent}
           end)
    -      |> expect(:close, fn :channel_pid_stub, :handle_id_stub -> :ok end)
    +      |> expect(:close, fn :channel_pid_stub, :handle_id_stub, _ ->
    +        :ok
    +      end)
    
           assert capture_log(fn ->
                    assert_raise IO.StreamError,
    @@ -79,16 +82,19 @@ defmodule SFTPClient.StreamTest do
           SFTPMock
           |> expect(:open, fn :channel_pid_stub,
                               'my/remote/path',
    -                          [:read, :binary] ->
    +                          [:read, :binary],
    +                          _ ->
             {:ok, :handle_id_stub}
           end)
    -      |> expect(:read, fn :channel_pid_stub, :handle_id_stub, 1337 ->
    +      |> expect(:read, fn :channel_pid_stub, :handle_id_stub, 1337, _ ->
             {:ok, "chunk 1"}
           end)
    -      |> expect(:read, fn :channel_pid_stub, :handle_id_stub, 1337 ->
    +      |> expect(:read, fn :channel_pid_stub, :handle_id_stub, 1337, _ ->
             {:ok, "chunk 2"}
           end)
    -      |> expect(:close, fn :channel_pid_stub, :handle_id_stub -> :ok end)
    +      |> expect(:close, fn :channel_pid_stub, :handle_id_stub, _ ->
    +        :ok
    +      end)
    
           assert Enum.member?(@stream, "chunk 2") == true
         end
    @@ -112,16 +118,19 @@ defmodule SFTPClient.StreamTest do
           SFTPMock
           |> expect(:open, fn :channel_pid_stub,
                               'my/remote/path',
    -                          [:write, :creat, :binary] ->
    +                          [:write, :creat, :binary],
    +                          _ ->
             {:ok, :handle_id_stub}
           end)
    -      |> expect(:write, fn :channel_pid_stub, :handle_id_stub, "chunk 1" ->
    +      |> expect(:write, fn :channel_pid_stub, :handle_id_stub, "chunk 1", _ ->
    +        :ok
    +      end)
    +      |> expect(:write, fn :channel_pid_stub, :handle_id_stub, "chunk 2", _ ->
             :ok
           end)
    -      |> expect(:write, fn :channel_pid_stub, :handle_id_stub, "chunk 2" ->
    +      |> expect(:close, fn :channel_pid_stub, :handle_id_stub, _ ->
             :ok
           end)
    -      |> expect(:close, fn :channel_pid_stub, :handle_id_stub -> :ok end)
    
           assert Enum.into(["chunk 1", "chunk 2"], @stream) == @stream
         end
    @@ -130,16 +139,19 @@ defmodule SFTPClient.StreamTest do
           SFTPMock
           |> expect(:open, fn :channel_pid_stub,
                               'my/remote/path',
    -                          [:write, :creat, :binary] ->
    +                          [:write, :creat, :binary],
    +                          _ ->
             {:ok, :handle_id_stub}
           end)
    -      |> expect(:write, fn :channel_pid_stub, :handle_id_stub, "chunk 1" ->
    +      |> expect(:write, fn :channel_pid_stub, :handle_id_stub, "chunk 1", _ ->
             :ok
           end)
    -      |> expect(:write, fn :channel_pid_stub, :handle_id_stub, "chunk 2" ->
    +      |> expect(:write, fn :channel_pid_stub, :handle_id_stub, "chunk 2", _ ->
             {:error, :generic_error}
           end)
    -      |> expect(:close, fn :channel_pid_stub, :handle_id_stub -> :ok end)
    +      |> expect(:close, fn :channel_pid_stub, :handle_id_stub, _ ->
    +        :ok
    +      end)
    
           assert_raise OperationError, "Operation failed: generic_error", fn ->
             Enum.into(["chunk 1", "chunk 2"], @stream)
    @@ -150,16 +162,19 @@ defmodule SFTPClient.StreamTest do
           SFTPMock
           |> expect(:open, fn :channel_pid_stub,
                               'my/remote/path',
    -                          [:write, :creat, :binary] ->
    +                          [:write, :creat, :binary],
    +                          _ ->
             {:ok, :handle_id_stub}
           end)
    -      |> expect(:write, fn :channel_pid_stub, :handle_id_stub, "chunk 1" ->
    +      |> expect(:write, fn :channel_pid_stub, :handle_id_stub, "chunk 1", _ ->
             :ok
           end)
    -      |> expect(:write, fn :channel_pid_stub, :handle_id_stub, "chunk 2" ->
    +      |> expect(:write, fn :channel_pid_stub, :handle_id_stub, "chunk 2", _ ->
             raise "Unexpected error"
           end)
    -      |> expect(:close, fn :channel_pid_stub, :handle_id_stub -> :ok end)
    +      |> expect(:close, fn :channel_pid_stub, :handle_id_stub, _ ->
    +        :ok
    +      end)
    
           assert_raise RuntimeError, "Unexpected error", fn ->
             assert Enum.into(["chunk 1", "chunk 2"], @stream)
    @@ -169,18 +184,23 @@ defmodule SFTPClient.StreamTest do
    
       defp setup_success_mocks do
         SFTPMock
    -    |> expect(:open, fn :channel_pid_stub, 'my/remote/path', [:read, :binary] ->
    +    |> expect(:open, fn :channel_pid_stub,
    +                        'my/remote/path',
    +                        [:read, :binary],
    +                        _ ->
           {:ok, :handle_id_stub}
         end)
    -    |> expect(:read, fn :channel_pid_stub, :handle_id_stub, 1337 ->
    +    |> expect(:read, fn :channel_pid_stub, :handle_id_stub, 1337, _ ->
           {:ok, "chunk 1"}
         end)
    -    |> expect(:read, fn :channel_pid_stub, :handle_id_stub, 1337 ->
    +    |> expect(:read, fn :channel_pid_stub, :handle_id_stub, 1337, _ ->
           {:ok, "chunk 2"}
         end)
    -    |> expect(:read, fn :channel_pid_stub, :handle_id_stub, 1337 ->
    +    |> expect(:read, fn :channel_pid_stub, :handle_id_stub, 1337, _ ->
           :eof
         end)
    -    |> expect(:close, fn :channel_pid_stub, :handle_id_stub -> :ok end)
    +    |> expect(:close, fn :channel_pid_stub, :handle_id_stub, _ ->
    +      :ok
    +    end)
       end
     end
    diff --git a/test/support/conn_helper.ex b/test/support/conn_helper.ex
    index 67cb1f9..f4ee152 100644
    --- a/test/support/conn_helper.ex
    +++ b/test/support/conn_helper.ex
    @@ -1,16 +1,16 @@
    -defmodule SFTPClient.ConnHelper do
    -  @moduledoc false
    -
    -  alias SFTPClient.Config
    -  alias SFTPClient.Conn
    -
    -  @spec build_conn(Config.t() | Keyword.t() | %{optional(atom) => any}) ::
    -          Conn.t()
    -  def build_conn(config_or_opts \\ []) do
    -    %Conn{
    -      config: Config.new(config_or_opts),
    -      channel_pid: :channel_pid_stub,
    -      conn_ref: :conn_ref_stub
    -    }
    -  end
    -end
    +defmodule SFTPClient.ConnHelper do
    +  @moduledoc false
    +
    +  alias SFTPClient.Config
    +  alias SFTPClient.Conn
    +
    +  @spec build_conn(Config.t() | Keyword.t() | %{optional(atom) => any}) ::
    +          Conn.t()
    +  def build_conn(config_or_opts \\ []) do
    +    %Conn{
    +      config: Config.new(config_or_opts),
    +      channel_pid: :channel_pid_stub,
    +      conn_ref: :conn_ref_stub
    +    }
    +  end
    +end
Commits on May 10, 2019
  1. Add support folder to compiled files in test env

    tlux committed May 10, 2019
  2. Add check formatted flag to script section in Travis config

    tlux committed May 10, 2019
  3. Add operation timeout

    tlux committed May 10, 2019
  4. Add operation timeout

    tlux committed May 10, 2019
  5. Remove unused file_info callback from SFTP adapter

    tlux committed May 10, 2019
  6. Fix typespecs

    tlux committed May 10, 2019
  7. Replace sample data in rename test with more realistic examples

    tlux committed May 10, 2019
  8. Add open_dir delegation to main module

    tlux committed May 10, 2019
  9. Simplify implementation of config validator

    tlux committed May 10, 2019
  10. Add callback variants of open_dir and fix typespecs

    tlux committed May 10, 2019
  11. Update version

    tlux committed May 10, 2019
  12. Add open_file/4 function variants with callbacks

    tlux committed May 10, 2019
  13. Add connect/2

    tlux committed May 10, 2019
  14. Remove unused Logger from Collectable implementation

    tlux committed May 10, 2019
  15. Update version in README

    tlux committed May 10, 2019
  16. Fix key provider

    tlux committed May 10, 2019
  17. Update docs

    tlux committed May 10, 2019
  18. Adds module docs to all operation

    tlux committed May 10, 2019
  19. Refactor Collectable for SFTPClient.Stream

    tlux committed May 10, 2019
  20. Add usage section to README

    tlux committed May 10, 2019
  21. Add upload_file operation

    tlux committed May 10, 2019
  22. Rename MakeSymlink to MakeLink to be consistent with the names of oth…

    tlux committed May 10, 2019
    …er symlink operations
Commits on May 9, 2019
  1. Update script in Travis config

    tlux committed May 9, 2019
  2. Remove doc link from Mixfile

    tlux committed May 9, 2019
  3. Convert Travis config to matrix

    tlux committed May 9, 2019
  4. Fix Travis config

    tlux committed May 9, 2019
  5. Add package config and build badge

    tlux committed May 9, 2019
Older
You can’t perform that action at this time.