Escape more paths and write a test

This commit is contained in:
David Stosik
2024-10-07 15:42:19 +09:00
parent 0840fdf0dd
commit d40057286d
2 changed files with 27 additions and 14 deletions

View File

@@ -149,6 +149,21 @@ class CommandsBuilderTest < ActiveSupport::TestCase
assert_equal "docker info --format '{{index .RegistryConfig.Mirrors 0}}'", command.first_mirror.join(" ")
end
test "clone path with spaces" do
command = new_builder_command
Kamal::Git.stubs(:root).returns("/absolute/path with spaces")
clone_command = command.clone.join(" ")
clone_reset_commands = command.clone_reset_steps.map { |a| a.join(" ") }
assert_match(%r{path\\ with\\ space}, clone_command)
refute_match(%r{path with spaces}, clone_command)
clone_reset_commands.each do |command|
assert_match(%r{path\\ with\\ space}, command)
refute_match(%r{path with spaces}, command)
end
end
private
def new_builder_command(additional_config = {})
Kamal::Commands::Builder.new(Kamal::Configuration.new(@config.deep_merge(additional_config), version: "123"))