From 1aab464b138dffad952c6ddd7a5f23f36de69e06 Mon Sep 17 00:00:00 2001 From: dstroch Date: Sat, 7 Oct 2023 19:12:03 +0200 Subject: [PATCH 1/2] Test cases when CLI raise an error --- test/onigumo_cli_test.exs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/onigumo_cli_test.exs b/test/onigumo_cli_test.exs index 56db75a..bc82eb5 100644 --- a/test/onigumo_cli_test.exs +++ b/test/onigumo_cli_test.exs @@ -20,5 +20,17 @@ defmodule OnigumoCLITest do File.cd(tmp_dir) Onigumo.CLI.main(["Downloader"]) end + + test("Onigumo CLI with invalid component name") do + assert_raise(ArgumentError, fn -> Onigumo.CLI.main(["invalid_name"]) end) + end + + test("Onigumo CLI with no component") do + assert_raise(FunctionClauseError, fn -> Onigumo.CLI.main([]) end) + end + + test("Onigumo CLI with more than one args ") do + assert_raise(FunctionClauseError, fn -> Onigumo.CLI.main(["Downloader", "Parser"]) end) + end end end From 48cac75ba2c5731720e2f40193543ecfe2111384 Mon Sep 17 00:00:00 2001 From: dstroch Date: Sat, 7 Oct 2023 19:23:58 +0200 Subject: [PATCH 2/2] Improve tests names --- test/onigumo_cli_test.exs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/onigumo_cli_test.exs b/test/onigumo_cli_test.exs index bc82eb5..37160c2 100644 --- a/test/onigumo_cli_test.exs +++ b/test/onigumo_cli_test.exs @@ -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) @@ -21,15 +21,15 @@ defmodule OnigumoCLITest do Onigumo.CLI.main(["Downloader"]) end - test("Onigumo CLI with invalid component name") do - assert_raise(ArgumentError, fn -> Onigumo.CLI.main(["invalid_name"]) end) + test("run CLI with unknown argument") do + assert_raise(ArgumentError, fn -> Onigumo.CLI.main(["Uploader"]) end) end - test("Onigumo CLI with no component") do + test("run CLI with no arguments") do assert_raise(FunctionClauseError, fn -> Onigumo.CLI.main([]) end) end - test("Onigumo CLI with more than one args ") do + test("run CLI with more than one argument") do assert_raise(FunctionClauseError, fn -> Onigumo.CLI.main(["Downloader", "Parser"]) end) end end