Skip to content

Commit 31669d4

Browse files
authored
Merge pull request #758 from basecamp/any-runtime-in-test
Accept any runtime in the hook tests
2 parents 9d20c14 + 69aa422 commit 31669d4

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

test/cli/cli_test_case.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def stub_setup
3838
.with { |arg1, arg2| arg1 == :rm && arg2 == ".kamal/locks/app/details" }
3939
end
4040

41-
def assert_hook_ran(hook, output, version:, service_version:, hosts:, command:, subcommand: nil, runtime: nil)
41+
def assert_hook_ran(hook, output, version:, service_version:, hosts:, command:, subcommand: nil, runtime: false)
4242
performer = `whoami`.strip
4343

4444
assert_match "Running the #{hook} hook...\n", output
@@ -52,7 +52,7 @@ def assert_hook_ran(hook, output, version:, service_version:, hosts:, command:,
5252
KAMAL_HOSTS=\"#{hosts}\"\s
5353
KAMAL_COMMAND=\"#{command}\"\s
5454
#{"KAMAL_SUBCOMMAND=\\\"#{subcommand}\\\"\\s" if subcommand}
55-
#{"KAMAL_RUNTIME=\\\"#{runtime}\\\"\\s" if runtime}
55+
#{"KAMAL_RUNTIME=\\\"\\d+\\\"\\s" if runtime}
5656
;\s/usr/bin/env\s\.kamal/hooks/#{hook} }x
5757

5858
assert_match expected, output

test/cli/main_test.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class CliMainTest < CliTestCase
6868
assert_match /Ensure app can pass healthcheck/, output
6969
assert_match /Detect stale containers/, output
7070
assert_match /Prune old containers and images/, output
71-
assert_hook_ran "post-deploy", output, **hook_variables, runtime: 0
71+
assert_hook_ran "post-deploy", output, **hook_variables, runtime: true
7272
end
7373
end
7474

@@ -211,7 +211,7 @@ class CliMainTest < CliTestCase
211211
assert_hook_ran "pre-deploy", output, **hook_variables
212212
assert_match /Running the pre-deploy hook.../, output
213213
assert_match /Ensure app can pass healthcheck/, output
214-
assert_hook_ran "post-deploy", output, **hook_variables, runtime: "0"
214+
assert_hook_ran "post-deploy", output, **hook_variables, runtime: true
215215
end
216216
end
217217

@@ -273,7 +273,7 @@ class CliMainTest < CliTestCase
273273
assert_match "docker tag dhh/app:123 dhh/app:latest", output
274274
assert_match "docker run --detach --restart unless-stopped --name app-web-123", output
275275
assert_match "docker container ls --all --filter name=^app-web-version-to-rollback$ --quiet | xargs docker stop", output, "Should stop the container that was previously running"
276-
assert_hook_ran "post-deploy", output, **hook_variables, runtime: "0"
276+
assert_hook_ran "post-deploy", output, **hook_variables, runtime: true
277277
end
278278
end
279279

0 commit comments

Comments
 (0)