Added destination to the lock directory

This commit is contained in:
Igor Alexandrov
2024-03-25 22:42:22 +04:00
parent 5f58575b62
commit 43672ec9a5
2 changed files with 7 additions and 5 deletions

View File

@@ -41,7 +41,9 @@ class Kamal::Commands::Lock < Kamal::Commands::Base
end end
def lock_dir def lock_dir
"#{config.run_directory}/lock-#{config.service}" dir_name = [ config.service, config.destination ].compact.join("-")
"#{config.run_directory}/lock-#{dir_name}"
end end
def lock_details_file def lock_details_file

View File

@@ -10,24 +10,24 @@ class CommandsLockTest < ActiveSupport::TestCase
test "status" do test "status" do
assert_equal \ assert_equal \
"stat .kamal/lock-app > /dev/null && cat .kamal/lock-app/details | base64 -d", "stat .kamal/lock-app-production > /dev/null && cat .kamal/lock-app-production/details | base64 -d",
new_command.status.join(" ") new_command.status.join(" ")
end end
test "acquire" do test "acquire" do
assert_match \ assert_match \
%r{mkdir \.kamal/lock-app && echo ".*" > \.kamal/lock-app/details}m, %r{mkdir \.kamal/lock-app-production && echo ".*" > \.kamal/lock-app-production/details}m,
new_command.acquire("Hello", "123").join(" ") new_command.acquire("Hello", "123").join(" ")
end end
test "release" do test "release" do
assert_match \ assert_match \
"rm .kamal/lock-app/details && rm -r .kamal/lock-app", "rm .kamal/lock-app-production/details && rm -r .kamal/lock-app-production",
new_command.release.join(" ") new_command.release.join(" ")
end end
private private
def new_command def new_command
Kamal::Commands::Lock.new(Kamal::Configuration.new(@config, version: "123")) Kamal::Commands::Lock.new(Kamal::Configuration.new(@config, version: "123", destination: "production"))
end end
end end