@@ -43,7 +43,7 @@ class CliMainTest < CliTestCase
43
43
with_test_secrets ( "secrets" => "DB_PASSWORD=secret" ) do
44
44
invoke_options = { "config_file" => "test/fixtures/deploy_simple.yml" , "version" => "999" , "skip_hooks" => false , "verbose" => true }
45
45
46
- Kamal ::Cli ::Main . any_instance . expects ( :invoke ) . with ( "kamal:cli:build:deliver" , [ ] , invoke_options )
46
+ Kamal ::Cli ::Main . any_instance . expects ( :invoke ) . with ( "kamal:cli:build:deliver" , [ ] , invoke_options )
47
47
Kamal ::Cli ::Main . any_instance . expects ( :invoke ) . with ( "kamal:cli:proxy:boot" , [ ] , invoke_options )
48
48
Kamal ::Cli ::Main . any_instance . expects ( :invoke ) . with ( "kamal:cli:app:stale_containers" , [ ] , invoke_options . merge ( stop : true ) )
49
49
Kamal ::Cli ::Main . any_instance . expects ( :invoke ) . with ( "kamal:cli:app:boot" , [ ] , invoke_options )
@@ -53,7 +53,7 @@ class CliMainTest < CliTestCase
53
53
54
54
run_command ( "deploy" , "--verbose" ) . tap do |output |
55
55
assert_hook_ran "pre-connect" , output
56
- assert_match /Build and push app image/ , output
56
+ assert_match /Build and push app image/ , output
57
57
assert_hook_ran "pre-deploy" , output
58
58
assert_match /Ensure kamal-proxy is running/ , output
59
59
assert_match /Detect stale containers/ , output
@@ -116,6 +116,32 @@ class CliMainTest < CliTestCase
116
116
end
117
117
end
118
118
119
+ test "deploy when inheriting lock" do
120
+ Thread . report_on_exception = false
121
+
122
+ invoke_options = { "config_file" => "test/fixtures/deploy_simple.yml" , "version" => "999" , "skip_hooks" => false }
123
+
124
+ Kamal ::Cli ::Main . any_instance . expects ( :invoke ) . with ( "kamal:cli:build:deliver" , [ ] , invoke_options )
125
+ Kamal ::Cli ::Main . any_instance . expects ( :invoke ) . with ( "kamal:cli:proxy:boot" , [ ] , invoke_options )
126
+ Kamal ::Cli ::Main . any_instance . expects ( :invoke ) . with ( "kamal:cli:app:stale_containers" , [ ] , invoke_options . merge ( stop : true ) )
127
+ Kamal ::Cli ::Main . any_instance . expects ( :invoke ) . with ( "kamal:cli:app:boot" , [ ] , invoke_options )
128
+ Kamal ::Cli ::Main . any_instance . expects ( :invoke ) . with ( "kamal:cli:prune:all" , [ ] , invoke_options )
129
+
130
+ Kamal ::Commands ::Hook . any_instance . stubs ( :hook_exists? ) . returns ( true )
131
+
132
+ with_kamal_lock_env do
133
+ KAMAL . reset
134
+ run_command ( "deploy" ) . tap do |output |
135
+ assert_no_match /Acquiring the deploy lock/ , output
136
+ assert_match /Build and push app image/ , output
137
+ assert_match /Ensure kamal-proxy is running/ , output
138
+ assert_match /Detect stale containers/ , output
139
+ assert_match /Prune old containers and images/ , output
140
+ assert_no_match /Releasing the deploy lock/ , output
141
+ end
142
+ end
143
+ end
144
+
119
145
test "deploy error when locking" do
120
146
Thread . report_on_exception = false
121
147
@@ -562,4 +588,11 @@ def with_config_files
562
588
def assert_file ( file , content )
563
589
assert_match content , File . read ( file )
564
590
end
591
+
592
+ def with_kamal_lock_env
593
+ ENV [ "KAMAL_LOCK" ] = "true"
594
+ yield
595
+ ensure
596
+ ENV . delete ( "KAMAL_LOCK" )
597
+ end
565
598
end
0 commit comments