Commander needn't accumulate configuration
Commander had version/destination solely to incrementally accumulate CLI options. Simpler to configure in one shot. Clarifies responsibility and lets us introduce things like `abbreviated_version` in one spot - Configuration.
This commit is contained in:
@@ -126,7 +126,7 @@ class CliMainTest < CliTestCase
|
||||
end
|
||||
|
||||
test "config" do
|
||||
run_command("config").tap do |output|
|
||||
run_command("config", config_file: "deploy_with_accessories").tap do |output|
|
||||
config = YAML.load(output)
|
||||
|
||||
assert_equal ["web"], config[:roles]
|
||||
@@ -138,6 +138,32 @@ class CliMainTest < CliTestCase
|
||||
end
|
||||
end
|
||||
|
||||
test "config with roles" do
|
||||
run_command("config", config_file: "deploy_with_roles").tap do |output|
|
||||
config = YAML.load(output)
|
||||
|
||||
assert_equal ["web", "workers"], config[:roles]
|
||||
assert_equal ["1.1.1.1", "1.1.1.2", "1.1.1.3", "1.1.1.4"], config[:hosts]
|
||||
assert_equal "999", config[:version]
|
||||
assert_equal "registry.digitalocean.com/dhh/app", config[:repository]
|
||||
assert_equal "registry.digitalocean.com/dhh/app:999", config[:absolute_image]
|
||||
assert_equal "app-999", config[:service_with_version]
|
||||
end
|
||||
end
|
||||
|
||||
test "config with destination" do
|
||||
run_command("config", "-d", "world", config_file: "deploy_for_dest").tap do |output|
|
||||
config = YAML.load(output)
|
||||
|
||||
assert_equal ["web"], config[:roles]
|
||||
assert_equal ["1.1.1.1", "1.1.1.2"], config[:hosts]
|
||||
assert_equal "999", config[:version]
|
||||
assert_equal "registry.digitalocean.com/dhh/app", config[:repository]
|
||||
assert_equal "registry.digitalocean.com/dhh/app:999", config[:absolute_image]
|
||||
assert_equal "app-999", config[:service_with_version]
|
||||
end
|
||||
end
|
||||
|
||||
test "init" do
|
||||
Pathname.any_instance.expects(:exist?).returns(false).twice
|
||||
FileUtils.stubs(:mkdir_p)
|
||||
@@ -227,7 +253,7 @@ class CliMainTest < CliTestCase
|
||||
end
|
||||
|
||||
private
|
||||
def run_command(*command)
|
||||
stdouted { Mrsk::Cli::Main.start([*command, "-c", "test/fixtures/deploy_with_accessories.yml"]) }
|
||||
def run_command(*command, config_file: "deploy_with_accessories")
|
||||
stdouted { Mrsk::Cli::Main.start([*command, "-c", "test/fixtures/#{config_file}.yml"]) }
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user