Added a basic CLI
This commit is contained in:
31
test/cli_test.exs
Normal file
31
test/cli_test.exs
Normal file
@@ -0,0 +1,31 @@
|
||||
defmodule CliTest do
|
||||
use ExUnit.Case
|
||||
doctest ElixirRss
|
||||
|
||||
import ElixirRss.CLI, only: [parse_args: 1]
|
||||
|
||||
test ":help returned for -h, --help, and default" do
|
||||
assert parse_args(["-h"]) == :help
|
||||
assert parse_args(["--help"]) == :help
|
||||
assert parse_args(["other", "-h", "stuff"]) == :help
|
||||
assert parse_args(["other", "--help", "stuff"]) == :help
|
||||
end
|
||||
|
||||
test "all switches given" do
|
||||
assert parse_args(["--host", "127.0.0.1", "--port", "80", "--path", "/path"]) == {"127.0.0.1", 80, "/path"}
|
||||
end
|
||||
|
||||
test "defaults returned for missing args" do
|
||||
assert parse_args([]) == {"0.0.0.0", 8080, "/"}
|
||||
assert parse_args(["--host", "127.0.0.1"]) == {"127.0.0.1", 8080, "/"}
|
||||
assert parse_args(["--port", "80"]) == {"0.0.0.0", 80, "/"}
|
||||
assert parse_args(["--path", "/path"]) == {"0.0.0.0", 8080, "/path"}
|
||||
assert parse_args(["--host", "127.0.0.1", "--port", "80"]) == {"127.0.0.1", 80, "/"}
|
||||
assert parse_args(["--host", "127.0.0.1", "--path", "/path"]) == {"127.0.0.1", 8080, "/path"}
|
||||
assert parse_args(["--port", "80", "--path", "/path"]) == {"0.0.0.0", 80, "/path"}
|
||||
end
|
||||
|
||||
test "out of order switches" do
|
||||
assert parse_args(["--port", "80", "--host", "127.0.0.1", "--path", "/path"]) == {"127.0.0.1", 80, "/path"}
|
||||
end
|
||||
end
|
||||
@@ -1,8 +1,8 @@
|
||||
defmodule ElixirRss.FetchTest do
|
||||
defmodule HttpTest do
|
||||
use ExUnit.Case
|
||||
doctest ElixirRss.Fetch
|
||||
doctest ElixirRss
|
||||
|
||||
test "fetch url" do
|
||||
assert ElixirRss.Fetch.fetch("https://shillerben.com") |> elem(0) == :ok
|
||||
assert ElixirRss.Http.fetch("https://shillerben.com") |> elem(0) == :ok
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user