From e6ca2705379dc66d15ee098110d66a474ab2d65e Mon Sep 17 00:00:00 2001 From: Igor Alexandrov Date: Sat, 15 Jul 2023 21:50:39 +0400 Subject: [PATCH] Include service name to lock details --- lib/mrsk/commands/lock.rb | 2 +- test/cli/cli_test_case.rb | 4 ++-- test/cli/main_test.rb | 8 ++++---- test/commands/lock_test.rb | 6 +++--- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/mrsk/commands/lock.rb b/lib/mrsk/commands/lock.rb index 6f84a5cc..6166d486 100644 --- a/lib/mrsk/commands/lock.rb +++ b/lib/mrsk/commands/lock.rb @@ -40,7 +40,7 @@ class Mrsk::Commands::Lock < Mrsk::Commands::Base end def lock_dir - :mrsk_lock + "mrsk_lock-#{config.service}" end def lock_details_file diff --git a/test/cli/cli_test_case.rb b/test/cli/cli_test_case.rb index 05b0ff9f..f094378d 100644 --- a/test/cli/cli_test_case.rb +++ b/test/cli/cli_test_case.rb @@ -29,9 +29,9 @@ class CliTestCase < ActiveSupport::TestCase def stub_locking SSHKit::Backend::Abstract.any_instance.stubs(:execute) - .with { |arg1, arg2| arg1 == :mkdir && arg2 == :mrsk_lock } + .with { |arg1, arg2| arg1 == :mkdir && arg2 == "mrsk_lock-app" } SSHKit::Backend::Abstract.any_instance.stubs(:execute) - .with { |arg1, arg2| arg1 == :rm && arg2 == "mrsk_lock/details" } + .with { |arg1, arg2| arg1 == :rm && arg2 == "mrsk_lock-app/details" } end def assert_hook_ran(hook, output, version:, service_version:, hosts:, command:, subcommand: nil, runtime: nil) diff --git a/test/cli/main_test.rb b/test/cli/main_test.rb index 728ce24e..730212ec 100644 --- a/test/cli/main_test.rb +++ b/test/cli/main_test.rb @@ -63,11 +63,11 @@ class CliMainTest < CliTestCase Thread.report_on_exception = false SSHKit::Backend::Abstract.any_instance.stubs(:execute) - .with { |*arg| arg[0..1] == [:mkdir, :mrsk_lock] } - .raises(RuntimeError, "mkdir: cannot create directory ‘mrsk_lock’: File exists") + .with { |*arg| arg[0..1] == [:mkdir, 'mrsk_lock-app'] } + .raises(RuntimeError, "mkdir: cannot create directory ‘mrsk_lock-app’: File exists") SSHKit::Backend::Abstract.any_instance.expects(:capture_with_debug) - .with(:stat, :mrsk_lock, ">", "/dev/null", "&&", :cat, "mrsk_lock/details", "|", :base64, "-d") + .with(:stat, 'mrsk_lock-app', ">", "/dev/null", "&&", :cat, "mrsk_lock-app/details", "|", :base64, "-d") assert_raises(Mrsk::Cli::LockError) do run_command("deploy") @@ -78,7 +78,7 @@ class CliMainTest < CliTestCase Thread.report_on_exception = false SSHKit::Backend::Abstract.any_instance.stubs(:execute) - .with { |*arg| arg[0..1] == [:mkdir, :mrsk_lock] } + .with { |*arg| arg[0..1] == [:mkdir, 'mrsk_lock-app'] } .raises(SocketError, "getaddrinfo: nodename nor servname provided, or not known") assert_raises(SSHKit::Runner::ExecuteError) do diff --git a/test/commands/lock_test.rb b/test/commands/lock_test.rb index bfb76597..f32aac07 100644 --- a/test/commands/lock_test.rb +++ b/test/commands/lock_test.rb @@ -10,19 +10,19 @@ class CommandsLockTest < ActiveSupport::TestCase test "status" do assert_equal \ - "stat mrsk_lock > /dev/null && cat mrsk_lock/details | base64 -d", + "stat mrsk_lock-app > /dev/null && cat mrsk_lock-app/details | base64 -d", new_command.status.join(" ") end test "acquire" do assert_match \ - /mkdir mrsk_lock && echo ".*" > mrsk_lock\/details/m, + /mkdir mrsk_lock-app && echo ".*" > mrsk_lock-app\/details/m, new_command.acquire("Hello", "123").join(" ") end test "release" do assert_match \ - "rm mrsk_lock/details && rm -r mrsk_lock", + "rm mrsk_lock-app/details && rm -r mrsk_lock-app", new_command.release.join(" ") end