-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: prepare for v0.5.0 release (#13)
* chore: prepare for v0.5.0 release * docs: update docs Also: - Added dialyzer CI Job * test: full test coverage * test: minor test tweak * feat: raise if invalid pipeline is defined
- Loading branch information
Showing
9 changed files
with
191 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
defmodule CommandexTest do | ||
use ExUnit.Case | ||
doctest Commandex | ||
alias Commandex.RegisterUser | ||
|
||
@email "[email protected]" | ||
@password "test1234" | ||
|
@@ -58,18 +57,105 @@ defmodule CommandexTest do | |
end | ||
end | ||
|
||
describe "param/2 macro" do | ||
test "raises if duplicate defined" do | ||
assert_raise ArgumentError, fn -> | ||
defmodule ExampleParamInvalid do | ||
import Commandex | ||
|
||
command do | ||
param :key_1 | ||
param :key_2 | ||
param :key_1 | ||
end | ||
end | ||
end | ||
end | ||
end | ||
|
||
describe "data/1 macro" do | ||
test "raises if duplicate defined" do | ||
assert_raise ArgumentError, fn -> | ||
defmodule ExampleDataInvalid do | ||
import Commandex | ||
|
||
command do | ||
data :key_1 | ||
data :key_2 | ||
data :key_1 | ||
end | ||
end | ||
end | ||
end | ||
end | ||
|
||
describe "pipeline/1 macro" do | ||
test "accepts valid pipeline arguments" do | ||
try do | ||
defmodule ExamplePipelineValid do | ||
import Commandex | ||
|
||
command do | ||
pipeline :example | ||
pipeline {ExamplePipelineValid, :example} | ||
pipeline {ExamplePipelineValid, :example_args, ["test"]} | ||
pipeline &ExamplePipelineValid.example_single/1 | ||
pipeline &ExamplePipelineValid.example/3 | ||
end | ||
|
||
def example(command, _params, _data) do | ||
command | ||
end | ||
|
||
def example_single(command) do | ||
command | ||
end | ||
|
||
def example_args(command, _params, _data, _custom_value) do | ||
command | ||
end | ||
end | ||
|
||
ExamplePipelineValid.run() | ||
rescue | ||
FunctionClauseError -> flunk("Should not raise.") | ||
end | ||
end | ||
|
||
test "raises if invalid argument defined" do | ||
assert_raise ArgumentError, fn -> | ||
defmodule ExamplePipelineInvalid do | ||
import Commandex | ||
|
||
command do | ||
pipeline 1234 | ||
end | ||
end | ||
end | ||
end | ||
end | ||
|
||
describe "halt/1" do | ||
test "ignores remaining pipelines" do | ||
command = RegisterUser.run(%{agree_tos: false}) | ||
|
||
refute command.success | ||
assert command.errors === %{tos: :not_accepted} | ||
end | ||
end | ||
|
||
describe "run/0" do | ||
test "is defined if no params are defined" do | ||
assert Kernel.function_exported?(Commandex.GenerateReport, :run, 0) | ||
assert Kernel.function_exported?(GenerateReport, :run, 0) | ||
|
||
command = Commandex.GenerateReport.run() | ||
command = GenerateReport.run() | ||
assert command.success | ||
assert command.data.total_valid > 0 | ||
assert command.data.total_invalid > 0 | ||
end | ||
|
||
test "is not defined if params are defined" do | ||
refute Kernel.function_exported?(Commandex.RegisterUser, :run, 0) | ||
refute Kernel.function_exported?(RegisterUser, :run, 0) | ||
end | ||
end | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters