-
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.
- Loading branch information
msawka
committed
Aug 7, 2015
1 parent
97698f3
commit c4d0cbe
Showing
2 changed files
with
47 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,26 +4,40 @@ defmodule OpenAperture.FleetManager.FleetAction.RestartUnitTest do | |
alias OpenAperture.FleetManager.Request, as: FleetRequest | ||
alias OpenAperture.FleetManager.FleetAction.RestartUnit | ||
|
||
alias OpenAperture.Fleet.EtcdCluster | ||
|
||
# =================================== | ||
# execute tests | ||
|
||
test "execute - invalid host_ip" do | ||
{status, response} = RestartUnit.execute(%FleetRequest{}) | ||
test "execute - no unit_name" do | ||
{status, response} = RestartUnit.execute(%FleetRequest{ | ||
action_parameters: %{ | ||
host_ip: "123.234.456.789" | ||
} | ||
}) | ||
assert status == :error | ||
assert response != nil | ||
end | ||
|
||
test "execute - no unit_name" do | ||
test "execute - no hosts available" do | ||
:meck.new(EtcdCluster, [:passthrough]) | ||
:meck.expect(EtcdCluster, :get_hosts, fn _ -> [] end) | ||
|
||
{status, response} = RestartUnit.execute(%FleetRequest{ | ||
action_parameters: %{ | ||
host_ip: "123.234.456.789" | ||
unit_name: "[email protected]" | ||
} | ||
}) | ||
assert status == :error | ||
assert response != nil | ||
end | ||
after | ||
:meck.unload(EtcdCluster) | ||
end | ||
|
||
test "execute - success" do | ||
:meck.new(EtcdCluster, [:passthrough]) | ||
:meck.expect(EtcdCluster, :get_hosts, fn _ -> [%FleetApi.Machine{primaryIP: "123.234.456.789"}, %FleetApi.Machine{primaryIP: "234.456.789.123"}] end) | ||
|
||
test "execute - nodes" do | ||
template = File.read!("#{System.cwd!()}/templates/node-info.sh.eex") | ||
|
||
:meck.new(File, [:unstick]) | ||
|
@@ -51,11 +65,15 @@ defmodule OpenAperture.FleetManager.FleetAction.RestartUnitTest do | |
assert status == :ok | ||
assert response != nil | ||
after | ||
:meck.unload(EtcdCluster) | ||
:meck.unload(File) | ||
:meck.unload(System) | ||
end | ||
|
||
test "execute - node info fails" do | ||
test "execute - fails" do | ||
:meck.new(EtcdCluster, [:passthrough]) | ||
:meck.expect(EtcdCluster, :get_hosts, fn _ -> [%FleetApi.Machine{primaryIP: "123.234.456.789"}, %FleetApi.Machine{primaryIP: "234.456.789.123"}] end) | ||
|
||
template = File.read!("#{System.cwd!()}/templates/node-info.sh.eex") | ||
|
||
:meck.new(File, [:unstick]) | ||
|
@@ -83,6 +101,7 @@ defmodule OpenAperture.FleetManager.FleetAction.RestartUnitTest do | |
assert status == :error | ||
assert response != nil | ||
after | ||
:meck.unload(EtcdCluster) | ||
:meck.unload(File) | ||
:meck.unload(System) | ||
end | ||
|