Builder::Remote.inspect_builder requires both checks to pass

Previously, if either of the builder or the remote context were in a
bad state, the build would proceed anyway and fail.
This commit is contained in:
Mike Dalessio
2025-07-17 11:06:52 -04:00
parent 4b88852aea
commit 8e470ed051
2 changed files with 19 additions and 1 deletions

View File

@@ -31,6 +31,24 @@ class CliBuildTest < CliTestCase
end
end
test "push with remote builder checks both the builder and the remote context" do
with_build_directory do |build_directory|
Kamal::Commands::Hook.any_instance.stubs(:hook_exists?).returns(true)
SSHKit::Backend::Abstract.any_instance.expects(:capture_with_info)
.with(:git, "-C", anything, :"rev-parse", :HEAD)
.returns(Kamal::Git.revision)
SSHKit::Backend::Abstract.any_instance.expects(:capture_with_info)
.with(:git, "-C", anything, :status, "--porcelain")
.returns("")
run_command("push", "--verbose", fixture: :with_remote_builder).tap do |output|
assert_match "docker buildx inspect kamal-remote-ssh---app-1-1-1-5 | grep -q Endpoint:.*kamal-remote-ssh---app-1-1-1-5-context && docker context inspect kamal-remote-ssh---app-1-1-1-5-context --format '{{.Endpoints.docker.Host}}' | grep -xq ssh://app@1.1.1.5 || (echo no compatible builder && exit 1)", output
end
end
end
test "push --output=docker" do
with_build_directory do |build_directory|
Kamal::Commands::Hook.any_instance.stubs(:hook_exists?).returns(true)