Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nappex committed Jan 26, 2024
1 parent 31d4f1e commit 58e365d
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions test/onigumo_cli_test.exs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
defmodule OnigumoCLITest do
use ExUnit.Case
import ExUnit.CaptureIO
import Mox

@urls [
Expand Down Expand Up @@ -33,15 +34,20 @@ defmodule OnigumoCLITest do
end

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

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

test("run CLI with invalid switch") do
assert_raise(OptionParser.ParseError, fn -> Onigumo.CLI.main(["--help"]) end)
assert usage_message_printed?(fn -> Onigumo.CLI.main(["--invalid"]) end)
end

defp usage_message_printed?(function) do
output = capture_io(function)
String.starts_with?(output, "Usage: onigumo ")
end
end
end

0 comments on commit 58e365d

Please sign in to comment.