Skip to content

Commit

Permalink
Merge pull request #192 from nappex/test-errors-cli
Browse files Browse the repository at this point in the history
Test cases when CLI raise an error
  • Loading branch information
Glutexo authored Oct 7, 2023
2 parents a8425aa + 48cac75 commit 67d0c90
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion test/onigumo_cli_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ defmodule OnigumoCLITest do

describe("Onigumo.CLI.main/1") do
@tag :tmp_dir
test("run Onigumo.CLI.main", %{tmp_dir: tmp_dir}) do
test("run CLI with 'Downloader' argument", %{tmp_dir: tmp_dir}) do
expect(HTTPoisonMock, :start, fn -> nil end)
expect(HTTPoisonMock, :get!, length(@urls), &HttpSupport.response/1)

Expand All @@ -20,5 +20,17 @@ defmodule OnigumoCLITest do
File.cd(tmp_dir)
Onigumo.CLI.main(["Downloader"])
end

test("run CLI with unknown argument") do
assert_raise(ArgumentError, fn -> Onigumo.CLI.main(["Uploader"]) end)
end

test("run CLI with no arguments") do
assert_raise(FunctionClauseError, fn -> Onigumo.CLI.main([]) end)
end

test("run CLI with more than one argument") do
assert_raise(FunctionClauseError, fn -> Onigumo.CLI.main(["Downloader", "Parser"]) end)
end
end
end

0 comments on commit 67d0c90

Please sign in to comment.