Reboot if running

This commit is contained in:
David Heinemeier Hansson
2023-02-03 13:52:31 +01:00
parent 3bd2559c03
commit 2023c377ab
2 changed files with 27 additions and 3 deletions

View File

@@ -5,6 +5,24 @@ class CliAppTest < CliTestCase
assert_match /Running docker run -d --restart unless-stopped/, run_command("boot")
end
test "boot will reboot if same version is already running" do
run_command("details") # Preheat MRSK const
# Prevent expected failures from outputting to terminal
Thread.report_on_exception = false
MRSK.app.stubs(:run).raises(SSHKit::Command::Failed.new("already in use")).then.returns([ :docker, :run ])
run_command("boot").tap do |output|
assert_match /Rebooting container with same version already deployed/, output # Can't start what's already running
assert_match /docker ps -q --filter label=service=app | xargs docker stop/, output # Stop what's running
assert_match /docker container ls -a -f name=app-999 -q | docker container rm/, output # Remove old container
assert_match /docker run/, output # Start new container
end
ensure
Thread.report_on_exception = true
end
test "reboot to default version" do
run_command("reboot").tap do |output|
assert_match /docker ps --filter label=service=app/, output # Find current container