Skip to content

Commit

Permalink
feat: raises if name is invalid
Browse files Browse the repository at this point in the history
Signed-off-by: Eduardo Borsa <borsa.dado@gmail.com>
  • Loading branch information
edborsa committed Dec 13, 2023
1 parent c2f46e7 commit f7be996
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/mix/tasks/install.ex
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ defmodule Mix.Tasks.Beacon.Install do

cond do
!Beacon.Types.Site.valid?(site) -> raise_with_help!("Invalid site name. It should not contain special characters.")
!Beacon.Types.Site.valid_name?(site) -> raise_with_help!("Invalid site name. The site name can't start with \"beacon_\".")
:default -> options
end
end
Expand Down
5 changes: 5 additions & 0 deletions test/mix/tasks/install_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,11 @@ defmodule Mix.Tasks.Beacon.InstallTest do
Install.run(["--site", "my@site!"])
end

# Invalid site name
assert_raise Mix.Error, fn ->
Install.run(["--site", "beacon_"])
end

# Invalid option
assert_raise OptionParser.ParseError, ~r/1 error found!\n--invalid-argument : Unknown option/, fn ->
Install.run(["--invalid-argument", "invalid"])
Expand Down

0 comments on commit f7be996

Please sign in to comment.