Added tests for network configuration option

This commit is contained in:
Igor Alexandrov
2024-10-01 20:24:28 +04:00
parent c917dd82cf
commit b6a10df56a
6 changed files with 49 additions and 0 deletions

View File

@@ -152,4 +152,13 @@ class ConfigurationAccessoryTest < ActiveSupport::TestCase
test "options" do
assert_equal [ "--cpus", "\"4\"", "--memory", "\"2GB\"" ], @config.accessory(:redis).option_args
end
test "network_args default" do
assert_equal [ "--network", "kamal" ], @config.accessory(:mysql).network_args
end
test "network_args with configured options" do
@deploy[:accessories]["mysql"]["network"] = "database"
assert_equal [ "--network", "database" ], @config.accessory(:mysql).network_args
end
end

View File

@@ -38,6 +38,15 @@ class ConfigurationProxyTest < ActiveSupport::TestCase
assert_not config.proxy.ssl?
end
test "network_args defaults" do
assert_equal [ "--network", "kamal" ], config.proxy.network_args
end
test "network_args with configured options" do
@deploy[:proxy] = { "network" => "example" }
assert_equal [ "--network", "example" ], config.proxy.network_args
end
private
def config
Kamal::Configuration.new(@deploy)

View File

@@ -217,6 +217,15 @@ class ConfigurationTest < ActiveSupport::TestCase
assert_equal [ "--log-driver", "\"local\"", "--log-opt", "max-size=\"100m\"", "--log-opt", "max-file=\"5\"" ], config.logging_args
end
test "network_args default" do
assert_equal [ "--network", "kamal" ], @config.network_args
end
test "network_args with configured options" do
config = Kamal::Configuration.new(@deploy.tap { |c| c.merge!(network: "custom") })
assert_equal [ "--network", "custom" ], config.network_args
end
test "erb evaluation of yml config" do
config = Kamal::Configuration.create_from config_file: Pathname.new(File.expand_path("fixtures/deploy.erb.yml", __dir__))
assert_equal "my-user", config.registry.username