Compare commits

..

1 Commits

Author SHA1 Message Date
Farah Schüller
eb2a9b5f72 Add test for custom per-role healthchecks
This adds the test for checking whether custom healthcheck options
in the role context are actually accepted into configuration.
2023-11-20 16:15:44 +01:00
3 changed files with 9 additions and 11 deletions

View File

@@ -93,7 +93,7 @@ class Kamal::Cli::Main < Kamal::Cli::Base
mutating do
invoke_options = deploy_options
KAMAL.config.version = Kamal::Git.used? ? Kamal::Git.resolve_revision(version) : version
KAMAL.config.version = version
old_version = nil
if container_available?(version)

View File

@@ -13,16 +13,6 @@ module Kamal::Git
`git rev-parse HEAD`.strip
end
# Attempt to convert a short -> long git sha, or return the original
def resolve_revision(revision)
resolved_rev = `git rev-parse -q --verify #{revision}`.strip
if resolved_rev.empty?
revision
else
resolved_rev
end
end
def uncommitted_changes
`git status --porcelain`.strip
end

View File

@@ -46,6 +46,14 @@ class CommandsHealthcheckTest < ActiveSupport::TestCase
new_command.run.join(" ")
end
test "run with custom per-role healthcheck options" do
@config[:servers] = { "web" => { "hosts" => [ "1.1.1.1" ],
"healthcheck" => { "log_lines" => 150 } } }
assert_equal \
"docker container ls --all --filter name=^healthcheck-app-123$ --quiet | xargs docker logs --tail 150 2>&1",
new_command.logs.join(" ")
end
test "status" do
assert_equal \
"docker container ls --all --filter name=^healthcheck-app-123$ --quiet | xargs docker inspect --format '{{if .State.Health}}{{.State.Health.Status}}{{else}}{{.State.Status}}{{end}}'",