Skip to content

Commit

Permalink
run the formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
intentionally-left-nil committed Jun 28, 2018
1 parent bf16865 commit ed837a0
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 8 deletions.
5 changes: 4 additions & 1 deletion lib/cli/commands/add/execute.ex
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@ defmodule Wand.CLI.Commands.Add.Execute do
else
{:error, :wand_file_load, reason} ->
WandFileWithHelp.handle_error(:wand_file_load, reason)

{:error, :wand_file_save, reason} ->
WandFileWithHelp.handle_error(:wand_file_save, reason)
{:error, step, reason} -> handle_error(step, reason)

{:error, step, reason} ->
handle_error(step, reason)
end
end

Expand Down
6 changes: 3 additions & 3 deletions lib/cli/commands/remove.ex
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ defmodule Wand.CLI.Commands.Remove do

def execute(names) do
with {:ok, file} <- WandFileWithHelp.load(),
file <- remove_names(file, names),
:ok <- WandFileWithHelp.save(file)
do
file <- remove_names(file, names),
:ok <- WandFileWithHelp.save(file) do
:ok
else
{:error, :wand_file_load, reason} ->
WandFileWithHelp.handle_error(:wand_file_load, reason)

{:error, :wand_file_save, reason} ->
WandFileWithHelp.handle_error(:wand_file_save, reason)
end
Expand Down
3 changes: 2 additions & 1 deletion lib/cli/wand_file_with_help.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ defmodule Wand.CLI.WandFileWithHelp do
alias Wand.WandFile
alias Wand.CLI.Display
import Wand.CLI.Errors, only: [error: 1]

def load() do
case WandFile.load() do
{:ok, file} -> {:ok, file}
Expand All @@ -28,7 +29,7 @@ defmodule Wand.CLI.WandFileWithHelp do
end

def handle_error(:wand_file_load, reason)
when reason in [:invalid_version, :missing_version, :version_mismatch] do
when reason in [:invalid_version, :missing_version, :version_mismatch] do
"""
# Error
The version field in wand.json is incorrect.
Expand Down
1 change: 1 addition & 0 deletions test/commands/add_execute_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ defmodule AddExecuteTest do
assert Add.execute([package]) == :ok
end
end

defp get_package(opts \\ []) do
fields =
%Package{}
Expand Down
9 changes: 6 additions & 3 deletions test/commands/remove_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -68,27 +68,30 @@ defmodule RemoveTest do
file = %WandFile{
dependencies: [
Helpers.WandFile.poison(),
Helpers.WandFile.mox(),
Helpers.WandFile.mox()
]
}

Helpers.WandFile.stub_load(file)

%WandFile{
dependencies: [
Helpers.WandFile.mox(),
Helpers.WandFile.mox()
]
}
|> Helpers.WandFile.stub_save()

assert Remove.execute(["poison"]) == :ok
end

test "removes multiple dependencies" do
file = %WandFile{
dependencies: [
Helpers.WandFile.poison(),
Helpers.WandFile.mox(),
Helpers.WandFile.mox()
]
}

Helpers.WandFile.stub_load(file)
Helpers.WandFile.stub_save(%WandFile{})
assert Remove.execute(["mox", "poison", "not_present"]) == :ok
Expand Down
1 change: 1 addition & 0 deletions test/wand_file_with_help_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ defmodule WandFileWithHelpTest do
Helpers.IO.stub_stderr()
:ok
end

test ":file_write_error when trying to save the file" do
file = %WandFile{}
Helpers.WandFile.stub_cannot_save(file)
Expand Down

0 comments on commit ed837a0

Please sign in to comment.