title: Mock function elixir
body: <p>I have a function like this</p>
  
  <pre><code>def foo_bar() do
    Enum.reduce_while(
      image_options,
      0,
      fn image_option, _foo -&gt;
        case image_option["destination"] do
          "s3" -&gt;
  
            case response = Upload.upload_on_s3(foo, bar) do
              {:ok, _} -&gt;
                {:cont, {:ok, "ok"}}
              {:error, _} -&gt;
                {:halt, response}
            end
          _ -&gt;
            {:cont, {:ok, "todo"}}
        end
      end
    )
  
  end
  </code></pre>
  
  <p>I want to test foo_bar in unit test. How can I mock <code>Upload.upload_on_s3(foo, bar)</code> function?</p>