Skip to content

Commit

Permalink
ex_tldr_test: insert Mox and write a possible test
Browse files Browse the repository at this point in the history
It is a "possible test" because it can not be implemented as it is,
because HTTPoison does not raise the defined exception. But it is
interesting to keep the test for the future implementation of the
necessary behaviour to adress this issue.
  • Loading branch information
ivanhercaz committed May 15, 2020
1 parent 041490c commit 75fede7
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions test/ex_tldr_test.exs
@@ -1,8 +1,13 @@
defmodule ExTldrTest do
use ExUnit.Case
import ExUnit.CaptureIO
alias ClientMock
doctest ExTldr

import Mox

setup :verify_on_exit!

test "look for a linux command" do
execute_main = fn ->
ExTldr.main(["linux", "adduser"])
Expand Down Expand Up @@ -58,4 +63,12 @@ defmodule ExTldrTest do

assert capture_io(execute_main) =~ "Usage:"
end

#test "should return lack of internet" do
# assert_raise NoInternetConnectionError,
# fn ->
# ClientMock
# |> expect(:get, fn _ -> {:error, %HTTPoison.Error{reason: :nxdomain}} end)
# end
#end
end

0 comments on commit 75fede7

Please sign in to comment.