Remove proxy only if no apps are installed
This commit is contained in:
@@ -98,11 +98,36 @@ class CliProxyTest < CliTestCase
|
||||
end
|
||||
|
||||
test "remove" do
|
||||
Kamal::Cli::Proxy.any_instance.expects(:stop)
|
||||
Kamal::Cli::Proxy.any_instance.expects(:remove_container)
|
||||
Kamal::Cli::Proxy.any_instance.expects(:remove_image)
|
||||
run_command("remove").tap do |output|
|
||||
assert_match "/usr/bin/env ls .kamal/apps | wc -l", output
|
||||
assert_match "docker container prune --force --filter label=org.opencontainers.image.title=kamal-proxy", output
|
||||
assert_match "docker image prune --all --force --filter label=org.opencontainers.image.title=kamal-proxy", output
|
||||
assert_match "/usr/bin/env rm -r .kamal/proxy", output
|
||||
end
|
||||
end
|
||||
|
||||
run_command("remove")
|
||||
test "remove with other apps" do
|
||||
Thread.report_on_exception = false
|
||||
|
||||
SSHKit::Backend::Abstract.any_instance.expects(:capture_with_info).with(:ls, ".kamal/apps", "|", :wc, "-l").returns("1\n").twice
|
||||
|
||||
run_command("remove").tap do |output|
|
||||
assert_match "Not removing the proxy, as other apps are installed, ignore this check with kamal proxy remove --force", output
|
||||
end
|
||||
ensure
|
||||
Thread.report_on_exception = true
|
||||
end
|
||||
|
||||
test "force remove with other apps" do
|
||||
Thread.report_on_exception = false
|
||||
|
||||
SSHKit::Backend::Abstract.any_instance.expects(:capture_with_info).with(:ls, ".kamal/apps", "|", :wc, "-l").returns("1\n").twice
|
||||
|
||||
run_command("remove").tap do |output|
|
||||
assert_match "Not removing the proxy, as other apps are installed, ignore this check with kamal proxy remove --force", output
|
||||
end
|
||||
ensure
|
||||
Thread.report_on_exception = true
|
||||
end
|
||||
|
||||
test "remove_container" do
|
||||
@@ -117,6 +142,12 @@ class CliProxyTest < CliTestCase
|
||||
end
|
||||
end
|
||||
|
||||
test "remove_host_directory" do
|
||||
run_command("remove_host_directory").tap do |output|
|
||||
assert_match "/usr/bin/env rm -r .kamal/proxy", output
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def run_command(*command, fixture: :with_proxy)
|
||||
stdouted { Kamal::Cli::Proxy.start([ *command, "-c", "test/fixtures/deploy_#{fixture}.yml" ]) }
|
||||
|
||||
Reference in New Issue
Block a user