capistrano 1.4.2 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +140 -4
- data/MIT-LICENSE +1 -1
- data/README +22 -14
- data/bin/cap +1 -8
- data/bin/capify +77 -0
- data/examples/sample.rb +10 -109
- data/lib/capistrano.rb +1 -0
- data/lib/capistrano/callback.rb +41 -0
- data/lib/capistrano/cli.rb +17 -317
- data/lib/capistrano/cli/execute.rb +82 -0
- data/lib/capistrano/cli/help.rb +102 -0
- data/lib/capistrano/cli/help.txt +53 -0
- data/lib/capistrano/cli/options.rb +183 -0
- data/lib/capistrano/cli/ui.rb +28 -0
- data/lib/capistrano/command.rb +62 -29
- data/lib/capistrano/configuration.rb +25 -226
- data/lib/capistrano/configuration/actions/file_transfer.rb +35 -0
- data/lib/capistrano/configuration/actions/inspect.rb +46 -0
- data/lib/capistrano/configuration/actions/invocation.rb +127 -0
- data/lib/capistrano/configuration/callbacks.rb +148 -0
- data/lib/capistrano/configuration/connections.rb +159 -0
- data/lib/capistrano/configuration/execution.rb +126 -0
- data/lib/capistrano/configuration/loading.rb +112 -0
- data/lib/capistrano/configuration/namespaces.rb +190 -0
- data/lib/capistrano/configuration/roles.rb +51 -0
- data/lib/capistrano/configuration/servers.rb +75 -0
- data/lib/capistrano/configuration/variables.rb +127 -0
- data/lib/capistrano/errors.rb +15 -0
- data/lib/capistrano/extensions.rb +27 -8
- data/lib/capistrano/gateway.rb +54 -29
- data/lib/capistrano/logger.rb +11 -11
- data/lib/capistrano/recipes/compat.rb +32 -0
- data/lib/capistrano/recipes/deploy.rb +483 -0
- data/lib/capistrano/recipes/deploy/dependencies.rb +44 -0
- data/lib/capistrano/recipes/deploy/local_dependency.rb +46 -0
- data/lib/capistrano/recipes/deploy/remote_dependency.rb +65 -0
- data/lib/capistrano/recipes/deploy/scm.rb +19 -0
- data/lib/capistrano/recipes/deploy/scm/base.rb +180 -0
- data/lib/capistrano/recipes/deploy/scm/bzr.rb +86 -0
- data/lib/capistrano/recipes/deploy/scm/cvs.rb +151 -0
- data/lib/capistrano/recipes/deploy/scm/darcs.rb +85 -0
- data/lib/capistrano/recipes/deploy/scm/mercurial.rb +129 -0
- data/lib/capistrano/recipes/deploy/scm/perforce.rb +126 -0
- data/lib/capistrano/recipes/deploy/scm/subversion.rb +103 -0
- data/lib/capistrano/recipes/deploy/strategy.rb +19 -0
- data/lib/capistrano/recipes/deploy/strategy/base.rb +64 -0
- data/lib/capistrano/recipes/deploy/strategy/checkout.rb +20 -0
- data/lib/capistrano/recipes/deploy/strategy/copy.rb +143 -0
- data/lib/capistrano/recipes/deploy/strategy/export.rb +20 -0
- data/lib/capistrano/recipes/deploy/strategy/remote.rb +52 -0
- data/lib/capistrano/recipes/deploy/strategy/remote_cache.rb +47 -0
- data/lib/capistrano/recipes/deploy/templates/maintenance.rhtml +53 -0
- data/lib/capistrano/recipes/standard.rb +26 -276
- data/lib/capistrano/recipes/templates/maintenance.rhtml +1 -1
- data/lib/capistrano/recipes/upgrade.rb +33 -0
- data/lib/capistrano/server_definition.rb +51 -0
- data/lib/capistrano/shell.rb +125 -81
- data/lib/capistrano/ssh.rb +80 -36
- data/lib/capistrano/task_definition.rb +69 -0
- data/lib/capistrano/upload.rb +146 -0
- data/lib/capistrano/version.rb +13 -17
- data/test/cli/execute_test.rb +132 -0
- data/test/cli/help_test.rb +139 -0
- data/test/cli/options_test.rb +226 -0
- data/test/cli/ui_test.rb +28 -0
- data/test/cli_test.rb +17 -0
- data/test/command_test.rb +284 -25
- data/test/configuration/actions/file_transfer_test.rb +40 -0
- data/test/configuration/actions/inspect_test.rb +62 -0
- data/test/configuration/actions/invocation_test.rb +195 -0
- data/test/configuration/callbacks_test.rb +206 -0
- data/test/configuration/connections_test.rb +288 -0
- data/test/configuration/execution_test.rb +159 -0
- data/test/configuration/loading_test.rb +119 -0
- data/test/configuration/namespace_dsl_test.rb +283 -0
- data/test/configuration/roles_test.rb +47 -0
- data/test/configuration/servers_test.rb +90 -0
- data/test/configuration/variables_test.rb +180 -0
- data/test/configuration_test.rb +60 -212
- data/test/deploy/scm/base_test.rb +55 -0
- data/test/deploy/strategy/copy_test.rb +146 -0
- data/test/extensions_test.rb +69 -0
- data/test/fixtures/cli_integration.rb +5 -0
- data/test/fixtures/custom.rb +2 -2
- data/test/gateway_test.rb +167 -0
- data/test/logger_test.rb +123 -0
- data/test/server_definition_test.rb +108 -0
- data/test/shell_test.rb +64 -0
- data/test/ssh_test.rb +67 -154
- data/test/task_definition_test.rb +101 -0
- data/test/upload_test.rb +131 -0
- data/test/utils.rb +31 -39
- data/test/version_test.rb +24 -0
- metadata +145 -98
- data/THANKS +0 -4
- data/lib/capistrano/actor.rb +0 -567
- data/lib/capistrano/generators/rails/deployment/deployment_generator.rb +0 -25
- data/lib/capistrano/generators/rails/deployment/templates/capistrano.rake +0 -49
- data/lib/capistrano/generators/rails/deployment/templates/deploy.rb +0 -122
- data/lib/capistrano/generators/rails/loader.rb +0 -20
- data/lib/capistrano/scm/base.rb +0 -61
- data/lib/capistrano/scm/baz.rb +0 -118
- data/lib/capistrano/scm/bzr.rb +0 -70
- data/lib/capistrano/scm/cvs.rb +0 -129
- data/lib/capistrano/scm/darcs.rb +0 -27
- data/lib/capistrano/scm/mercurial.rb +0 -83
- data/lib/capistrano/scm/perforce.rb +0 -139
- data/lib/capistrano/scm/subversion.rb +0 -128
- data/lib/capistrano/transfer.rb +0 -97
- data/lib/capistrano/utils.rb +0 -26
- data/test/actor_test.rb +0 -402
- data/test/scm/cvs_test.rb +0 -196
- data/test/scm/subversion_test.rb +0 -145
data/test/configuration_test.rb
CHANGED
@@ -1,233 +1,81 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require 'test/unit'
|
1
|
+
require "#{File.dirname(__FILE__)}/utils"
|
4
2
|
require 'capistrano/configuration'
|
5
|
-
require 'flexmock'
|
6
3
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
def initialize(config)
|
12
|
-
end
|
13
|
-
|
14
|
-
def define_task(*args, &block)
|
15
|
-
(@tasks ||= []).push [args, block].flatten
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
class MockSCM
|
20
|
-
attr_reader :configuration
|
21
|
-
|
22
|
-
def initialize(config)
|
23
|
-
@configuration = config
|
24
|
-
end
|
25
|
-
end
|
4
|
+
# These tests are only for testing the integration of the various components
|
5
|
+
# of the Configuration class. To test specific features, please look at the
|
6
|
+
# tests under test/configuration.
|
26
7
|
|
8
|
+
class ConfigurationTest < Test::Unit::TestCase
|
27
9
|
def setup
|
28
|
-
@config = Capistrano::Configuration.new
|
29
|
-
@config.set :scm, MockSCM
|
30
|
-
end
|
31
|
-
|
32
|
-
def test_version_dir_default
|
33
|
-
assert "releases", @config.version_dir
|
34
|
-
end
|
35
|
-
|
36
|
-
def test_current_dir_default
|
37
|
-
assert "current", @config.current_dir
|
38
|
-
end
|
39
|
-
|
40
|
-
def test_shared_dir_default
|
41
|
-
assert "shared", @config.shared_dir
|
42
|
-
end
|
43
|
-
|
44
|
-
def test_set_repository
|
45
|
-
@config.set :repository, "/foo/bar/baz"
|
46
|
-
assert_equal "/foo/bar/baz", @config.repository
|
47
|
-
end
|
48
|
-
|
49
|
-
def test_set_user
|
50
|
-
@config.set :user, "flippy"
|
51
|
-
assert_equal "flippy", @config.user
|
52
|
-
end
|
53
|
-
|
54
|
-
def test_define_single_role
|
55
|
-
@config.role :app, "somewhere.example.com"
|
56
|
-
assert_equal 1, @config.roles[:app].length
|
57
|
-
assert_equal "somewhere.example.com", @config.roles[:app].first.host
|
58
|
-
assert_equal Hash.new, @config.roles[:app].first.options
|
59
|
-
end
|
60
|
-
|
61
|
-
def test_define_single_role_with_options
|
62
|
-
@config.role :app, "somewhere.example.com", :primary => true
|
63
|
-
assert_equal 1, @config.roles[:app].length
|
64
|
-
assert_equal "somewhere.example.com", @config.roles[:app].first.host
|
65
|
-
assert_equal({:primary => true}, @config.roles[:app].first.options)
|
66
|
-
end
|
67
|
-
|
68
|
-
def test_define_multi_role
|
69
|
-
@config.role :app, "somewhere.example.com", "else.example.com"
|
70
|
-
assert_equal 2, @config.roles[:app].length
|
71
|
-
assert_equal "somewhere.example.com", @config.roles[:app].first.host
|
72
|
-
assert_equal "else.example.com", @config.roles[:app].last.host
|
73
|
-
assert_equal({}, @config.roles[:app].first.options)
|
74
|
-
assert_equal({}, @config.roles[:app].last.options)
|
75
|
-
end
|
76
|
-
|
77
|
-
def test_define_multi_role_with_options
|
78
|
-
@config.role :app, "somewhere.example.com", "else.example.com", :primary => true
|
79
|
-
assert_equal 2, @config.roles[:app].length
|
80
|
-
assert_equal "somewhere.example.com", @config.roles[:app].first.host
|
81
|
-
assert_equal "else.example.com", @config.roles[:app].last.host
|
82
|
-
assert_equal({:primary => true}, @config.roles[:app].first.options)
|
83
|
-
assert_equal({:primary => true}, @config.roles[:app].last.options)
|
84
|
-
end
|
85
|
-
|
86
|
-
def test_load_string_unnamed
|
87
|
-
@config.load :string => "set :repository, __FILE__"
|
88
|
-
assert_equal "<eval>", @config.repository
|
89
|
-
end
|
90
|
-
|
91
|
-
def test_load_string_named
|
92
|
-
@config.load :string => "set :repository, __FILE__", :name => "test.rb"
|
93
|
-
assert_equal "test.rb", @config.repository
|
10
|
+
@config = Capistrano::Configuration.new
|
94
11
|
end
|
95
12
|
|
96
|
-
def
|
97
|
-
|
98
|
-
@config.
|
99
|
-
assert_equal "1/2/foo", @config.repository
|
100
|
-
assert_equal "./#{file}.example.com", @config.gateway
|
101
|
-
assert_equal 1, @config.roles[:web].length
|
102
|
-
end
|
103
|
-
|
104
|
-
def test_load_explicit_name
|
105
|
-
file = File.dirname(__FILE__) + "/fixtures/config.rb"
|
106
|
-
@config.load file, :name => "config"
|
107
|
-
assert_equal "1/2/foo", @config.repository
|
108
|
-
assert_equal "config.example.com", @config.gateway
|
109
|
-
assert_equal 1, @config.roles[:web].length
|
110
|
-
end
|
111
|
-
|
112
|
-
def test_load_file_implied_name
|
113
|
-
file = File.dirname(__FILE__) + "/fixtures/config.rb"
|
114
|
-
@config.load :file => file
|
115
|
-
assert_equal "1/2/foo", @config.repository
|
116
|
-
assert_equal "./#{file}.example.com", @config.gateway
|
117
|
-
assert_equal 1, @config.roles[:web].length
|
118
|
-
end
|
119
|
-
|
120
|
-
def test_load_file_explicit_name
|
121
|
-
file = File.dirname(__FILE__) + "/fixtures/config.rb"
|
122
|
-
@config.load :file => file, :name => "config"
|
123
|
-
assert_equal "1/2/foo", @config.repository
|
124
|
-
assert_equal "config.example.com", @config.gateway
|
125
|
-
assert_equal 1, @config.roles[:web].length
|
126
|
-
end
|
127
|
-
|
128
|
-
def test_load_proc_explicit
|
129
|
-
@config.load :proc => Proc.new { set :gateway, "nifty.zoo.test" }
|
130
|
-
assert_equal "nifty.zoo.test", @config.gateway
|
131
|
-
end
|
132
|
-
|
133
|
-
def test_load_proc_implicit
|
134
|
-
@config.load { set :gateway, "nifty.zoo.test" }
|
135
|
-
assert_equal "nifty.zoo.test", @config.gateway
|
136
|
-
end
|
137
|
-
|
138
|
-
def test_task_without_options
|
139
|
-
block = Proc.new { }
|
140
|
-
@config.task :hello, &block
|
141
|
-
assert_equal 1, @config.actor.tasks.length
|
142
|
-
assert_equal :hello, @config.actor.tasks[0][0]
|
143
|
-
assert_equal({}, @config.actor.tasks[0][1])
|
144
|
-
assert_equal block, @config.actor.tasks[0][2]
|
145
|
-
end
|
146
|
-
|
147
|
-
def test_task_with_options
|
148
|
-
block = Proc.new { }
|
149
|
-
@config.task :hello, :roles => :app, &block
|
150
|
-
assert_equal 1, @config.actor.tasks.length
|
151
|
-
assert_equal :hello, @config.actor.tasks[0][0]
|
152
|
-
assert_equal({:roles => :app}, @config.actor.tasks[0][1])
|
153
|
-
assert_equal block, @config.actor.tasks[0][2]
|
154
|
-
end
|
155
|
-
|
156
|
-
def test_source
|
157
|
-
@config.set :repository, "/foo/bar/baz"
|
158
|
-
assert_equal "/foo/bar/baz", @config.source.configuration.repository
|
159
|
-
end
|
13
|
+
def test_connections_execution_loading_namespaces_roles_and_variables_modules_should_integrate_correctly
|
14
|
+
Capistrano::SSH.expects(:connect).with { |s,c| s.host == "www.capistrano.test" && c == @config }.returns(:session)
|
15
|
+
Capistrano::Command.expects(:process).with("echo 'hello world'", [:session], :logger => @config.logger)
|
160
16
|
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
end
|
171
|
-
|
172
|
-
def test_current_path_default
|
173
|
-
@config.set :deploy_to, "/start/of/path"
|
174
|
-
assert_equal "/start/of/path/current", @config.current_path
|
175
|
-
end
|
176
|
-
|
177
|
-
def test_current_path_custom
|
178
|
-
@config.set :deploy_to, "/start/of/path"
|
179
|
-
@config.set :current_dir, "right/here"
|
180
|
-
assert_equal "/start/of/path/right/here", @config.current_path
|
181
|
-
end
|
182
|
-
|
183
|
-
def test_shared_path_default
|
184
|
-
@config.set :deploy_to, "/start/of/path"
|
185
|
-
assert_equal "/start/of/path/shared", @config.shared_path
|
186
|
-
end
|
17
|
+
@config.load do
|
18
|
+
role :test, "www.capistrano.test"
|
19
|
+
set :message, "hello world"
|
20
|
+
namespace :testing do
|
21
|
+
task :example, :roles => :test do
|
22
|
+
run "echo '#{message}'"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
187
26
|
|
188
|
-
|
189
|
-
@config.set :deploy_to, "/start/of/path"
|
190
|
-
@config.set :shared_dir, "right/here"
|
191
|
-
assert_equal "/start/of/path/right/here", @config.shared_path
|
27
|
+
@config.testing.example
|
192
28
|
end
|
193
29
|
|
194
|
-
def
|
195
|
-
@config.
|
196
|
-
|
197
|
-
|
30
|
+
def test_tasks_in_nested_namespace_should_be_able_to_call_tasks_in_same_namespace
|
31
|
+
@config.namespace(:outer) do
|
32
|
+
task(:first) { set :called_first, true }
|
33
|
+
namespace(:inner) do
|
34
|
+
task(:first) { set :called_inner_first, true }
|
35
|
+
task(:second) { first }
|
36
|
+
end
|
37
|
+
end
|
198
38
|
|
199
|
-
|
200
|
-
|
201
|
-
|
39
|
+
@config.outer.inner.second
|
40
|
+
assert !@config[:called_first]
|
41
|
+
assert @config[:called_inner_first]
|
202
42
|
end
|
203
43
|
|
204
|
-
def
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
44
|
+
def test_tasks_in_nested_namespace_should_be_able_to_call_tasks_in_parent_namespace
|
45
|
+
@config.namespace(:outer) do
|
46
|
+
task(:first) { set :called_first, true }
|
47
|
+
namespace(:inner) do
|
48
|
+
task(:second) { first }
|
49
|
+
end
|
50
|
+
end
|
210
51
|
|
211
|
-
|
212
|
-
@config
|
213
|
-
assert_equal "Capistrano::SCM::Darcs", @config.source.class.name
|
52
|
+
@config.outer.inner.second
|
53
|
+
assert @config[:called_first]
|
214
54
|
end
|
215
55
|
|
216
|
-
def
|
217
|
-
@config.
|
218
|
-
|
219
|
-
|
56
|
+
def test_tasks_in_nested_namespace_should_be_able_to_call_shadowed_tasks_in_parent_namespace
|
57
|
+
@config.namespace(:outer) do
|
58
|
+
task(:first) { set :called_first, true }
|
59
|
+
namespace(:inner) do
|
60
|
+
task(:first) { set :called_inner_first, true }
|
61
|
+
task(:second) { parent.first }
|
62
|
+
end
|
63
|
+
end
|
220
64
|
|
221
|
-
|
222
|
-
@config
|
223
|
-
|
224
|
-
assert_equal "foo", @config[:proc]
|
225
|
-
assert_not_nil @config[:original_value][:proc]
|
226
|
-
assert @config[:original_value][:proc].respond_to?(:call)
|
65
|
+
@config.outer.inner.second
|
66
|
+
assert @config[:called_first]
|
67
|
+
assert !@config[:called_inner_first]
|
227
68
|
end
|
228
69
|
|
229
|
-
def
|
230
|
-
@config.
|
231
|
-
|
70
|
+
def test_hooks_for_default_task_should_be_found_if_named_after_the_namespace
|
71
|
+
@config.namespace(:outer) do
|
72
|
+
task(:default) { set :called_default, true }
|
73
|
+
task(:before_outer) { set :called_before_outer, true }
|
74
|
+
task(:after_outer) { set :called_after_outer, true }
|
75
|
+
end
|
76
|
+
@config.outer.default
|
77
|
+
assert @config[:called_before_outer]
|
78
|
+
assert @config[:called_default]
|
79
|
+
assert @config[:called_after_outer]
|
232
80
|
end
|
233
81
|
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require "#{File.dirname(__FILE__)}/../../utils"
|
2
|
+
require 'capistrano/recipes/deploy/scm/base'
|
3
|
+
|
4
|
+
class DeploySCMBaseTest < Test::Unit::TestCase
|
5
|
+
class TestSCM < Capistrano::Deploy::SCM::Base
|
6
|
+
default_command "floopy"
|
7
|
+
end
|
8
|
+
|
9
|
+
def setup
|
10
|
+
@config = { }
|
11
|
+
def @config.exists?(name); key?(name); end
|
12
|
+
|
13
|
+
@source = TestSCM.new(@config)
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_command_should_default_to_default_command
|
17
|
+
assert_equal "floopy", @source.command
|
18
|
+
@source.local { assert_equal "floopy", @source.command }
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_command_should_use_scm_command_if_available
|
22
|
+
@config[:scm_command] = "/opt/local/bin/floopy"
|
23
|
+
assert_equal "/opt/local/bin/floopy", @source.command
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_command_should_use_scm_command_in_local_mode_if_local_scm_command_not_set
|
27
|
+
@config[:scm_command] = "/opt/local/bin/floopy"
|
28
|
+
@source.local { assert_equal "/opt/local/bin/floopy", @source.command }
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_command_should_use_local_scm_command_in_local_mode_if_local_scm_command_is_set
|
32
|
+
@config[:scm_command] = "/opt/local/bin/floopy"
|
33
|
+
@config[:local_scm_command] = "/usr/local/bin/floopy"
|
34
|
+
assert_equal "/opt/local/bin/floopy", @source.command
|
35
|
+
@source.local { assert_equal "/usr/local/bin/floopy", @source.command }
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_command_should_use_default_if_scm_command_is_default
|
39
|
+
@config[:scm_command] = :default
|
40
|
+
assert_equal "floopy", @source.command
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_command_should_use_default_in_local_mode_if_local_scm_command_is_default
|
44
|
+
@config[:scm_command] = "/foo/bar/floopy"
|
45
|
+
@config[:local_scm_command] = :default
|
46
|
+
@source.local { assert_equal "floopy", @source.command }
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_local_mode_proxy_should_treat_messages_as_being_in_local_mode
|
50
|
+
@config[:scm_command] = "/foo/bar/floopy"
|
51
|
+
@config[:local_scm_command] = :default
|
52
|
+
assert_equal "floopy", @source.local.command
|
53
|
+
assert_equal "/foo/bar/floopy", @source.command
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,146 @@
|
|
1
|
+
require "#{File.dirname(__FILE__)}/../../utils"
|
2
|
+
require 'capistrano/logger'
|
3
|
+
require 'capistrano/recipes/deploy/strategy/copy'
|
4
|
+
|
5
|
+
class DeployStrategyCopyTest < Test::Unit::TestCase
|
6
|
+
def setup
|
7
|
+
@config = { :logger => Capistrano::Logger.new(:output => StringIO.new),
|
8
|
+
:releases_path => "/u/apps/test/releases",
|
9
|
+
:release_path => "/u/apps/test/releases/1234567890",
|
10
|
+
:real_revision => "154" }
|
11
|
+
@source = mock("source")
|
12
|
+
@config.stubs(:source).returns(@source)
|
13
|
+
@strategy = Capistrano::Deploy::Strategy::Copy.new(@config)
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_deploy_with_defaults_should_use_tar_gz_and_checkout
|
17
|
+
Dir.expects(:tmpdir).returns("/temp/dir")
|
18
|
+
Dir.expects(:chdir).with("/temp/dir").yields
|
19
|
+
@source.expects(:checkout).with("154", "/temp/dir/1234567890").returns(:local_checkout)
|
20
|
+
|
21
|
+
@strategy.expects(:system).with(:local_checkout)
|
22
|
+
@strategy.expects(:system).with("tar czf 1234567890.tar.gz 1234567890")
|
23
|
+
@strategy.expects(:put).with(:mock_file_contents, "/tmp/1234567890.tar.gz")
|
24
|
+
@strategy.expects(:run).with("cd /u/apps/test/releases && tar xzf /tmp/1234567890.tar.gz && rm /tmp/1234567890.tar.gz")
|
25
|
+
|
26
|
+
mock_file = mock("file")
|
27
|
+
mock_file.expects(:puts).with("154")
|
28
|
+
File.expects(:open).with("/temp/dir/1234567890/REVISION", "w").yields(mock_file)
|
29
|
+
File.expects(:read).with("/temp/dir/1234567890.tar.gz").returns(:mock_file_contents)
|
30
|
+
|
31
|
+
FileUtils.expects(:rm).with("/temp/dir/1234567890.tar.gz")
|
32
|
+
FileUtils.expects(:rm_rf).with("/temp/dir/1234567890")
|
33
|
+
|
34
|
+
@strategy.deploy!
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_deploy_with_export_should_use_tar_gz_and_export
|
38
|
+
Dir.expects(:tmpdir).returns("/temp/dir")
|
39
|
+
Dir.expects(:chdir).with("/temp/dir").yields
|
40
|
+
@config[:copy_strategy] = :export
|
41
|
+
@source.expects(:export).with("154", "/temp/dir/1234567890").returns(:local_export)
|
42
|
+
|
43
|
+
@strategy.expects(:system).with(:local_export)
|
44
|
+
@strategy.expects(:system).with("tar czf 1234567890.tar.gz 1234567890")
|
45
|
+
@strategy.expects(:put).with(:mock_file_contents, "/tmp/1234567890.tar.gz")
|
46
|
+
@strategy.expects(:run).with("cd /u/apps/test/releases && tar xzf /tmp/1234567890.tar.gz && rm /tmp/1234567890.tar.gz")
|
47
|
+
|
48
|
+
mock_file = mock("file")
|
49
|
+
mock_file.expects(:puts).with("154")
|
50
|
+
File.expects(:open).with("/temp/dir/1234567890/REVISION", "w").yields(mock_file)
|
51
|
+
File.expects(:read).with("/temp/dir/1234567890.tar.gz").returns(:mock_file_contents)
|
52
|
+
|
53
|
+
FileUtils.expects(:rm).with("/temp/dir/1234567890.tar.gz")
|
54
|
+
FileUtils.expects(:rm_rf).with("/temp/dir/1234567890")
|
55
|
+
|
56
|
+
@strategy.deploy!
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_deploy_with_zip_should_use_zip_and_checkout
|
60
|
+
Dir.expects(:tmpdir).returns("/temp/dir")
|
61
|
+
Dir.expects(:chdir).with("/temp/dir").yields
|
62
|
+
@config[:copy_compression] = :zip
|
63
|
+
@source.expects(:checkout).with("154", "/temp/dir/1234567890").returns(:local_checkout)
|
64
|
+
|
65
|
+
@strategy.expects(:system).with(:local_checkout)
|
66
|
+
@strategy.expects(:system).with("zip -qr 1234567890.zip 1234567890")
|
67
|
+
@strategy.expects(:put).with(:mock_file_contents, "/tmp/1234567890.zip")
|
68
|
+
@strategy.expects(:run).with("cd /u/apps/test/releases && unzip -q /tmp/1234567890.zip && rm /tmp/1234567890.zip")
|
69
|
+
|
70
|
+
mock_file = mock("file")
|
71
|
+
mock_file.expects(:puts).with("154")
|
72
|
+
File.expects(:open).with("/temp/dir/1234567890/REVISION", "w").yields(mock_file)
|
73
|
+
File.expects(:read).with("/temp/dir/1234567890.zip").returns(:mock_file_contents)
|
74
|
+
|
75
|
+
FileUtils.expects(:rm).with("/temp/dir/1234567890.zip")
|
76
|
+
FileUtils.expects(:rm_rf).with("/temp/dir/1234567890")
|
77
|
+
|
78
|
+
@strategy.deploy!
|
79
|
+
end
|
80
|
+
|
81
|
+
def test_deploy_with_bzip2_should_use_zip_and_checkout
|
82
|
+
Dir.expects(:tmpdir).returns("/temp/dir")
|
83
|
+
Dir.expects(:chdir).with("/temp/dir").yields
|
84
|
+
@config[:copy_compression] = :bzip2
|
85
|
+
@source.expects(:checkout).with("154", "/temp/dir/1234567890").returns(:local_checkout)
|
86
|
+
|
87
|
+
@strategy.expects(:system).with(:local_checkout)
|
88
|
+
@strategy.expects(:system).with("tar cjf 1234567890.tar.bz2 1234567890")
|
89
|
+
@strategy.expects(:put).with(:mock_file_contents, "/tmp/1234567890.tar.bz2")
|
90
|
+
@strategy.expects(:run).with("cd /u/apps/test/releases && tar xjf /tmp/1234567890.tar.bz2 && rm /tmp/1234567890.tar.bz2")
|
91
|
+
|
92
|
+
mock_file = mock("file")
|
93
|
+
mock_file.expects(:puts).with("154")
|
94
|
+
File.expects(:open).with("/temp/dir/1234567890/REVISION", "w").yields(mock_file)
|
95
|
+
File.expects(:read).with("/temp/dir/1234567890.tar.bz2").returns(:mock_file_contents)
|
96
|
+
|
97
|
+
FileUtils.expects(:rm).with("/temp/dir/1234567890.tar.bz2")
|
98
|
+
FileUtils.expects(:rm_rf).with("/temp/dir/1234567890")
|
99
|
+
|
100
|
+
@strategy.deploy!
|
101
|
+
end
|
102
|
+
|
103
|
+
def test_deploy_with_custom_copy_dir_should_use_that_as_tmpdir
|
104
|
+
Dir.expects(:tmpdir).never
|
105
|
+
Dir.expects(:chdir).with("/other/path").yields
|
106
|
+
@config[:copy_dir] = "/other/path"
|
107
|
+
@source.expects(:checkout).with("154", "/other/path/1234567890").returns(:local_checkout)
|
108
|
+
|
109
|
+
@strategy.expects(:system).with(:local_checkout)
|
110
|
+
@strategy.expects(:system).with("tar czf 1234567890.tar.gz 1234567890")
|
111
|
+
@strategy.expects(:put).with(:mock_file_contents, "/tmp/1234567890.tar.gz")
|
112
|
+
@strategy.expects(:run).with("cd /u/apps/test/releases && tar xzf /tmp/1234567890.tar.gz && rm /tmp/1234567890.tar.gz")
|
113
|
+
|
114
|
+
mock_file = mock("file")
|
115
|
+
mock_file.expects(:puts).with("154")
|
116
|
+
File.expects(:open).with("/other/path/1234567890/REVISION", "w").yields(mock_file)
|
117
|
+
File.expects(:read).with("/other/path/1234567890.tar.gz").returns(:mock_file_contents)
|
118
|
+
|
119
|
+
FileUtils.expects(:rm).with("/other/path/1234567890.tar.gz")
|
120
|
+
FileUtils.expects(:rm_rf).with("/other/path/1234567890")
|
121
|
+
|
122
|
+
@strategy.deploy!
|
123
|
+
end
|
124
|
+
|
125
|
+
def test_deploy_with_copy_remote_dir_should_copy_to_that_dir
|
126
|
+
@config[:copy_remote_dir] = "/somewhere/else"
|
127
|
+
Dir.expects(:tmpdir).returns("/temp/dir")
|
128
|
+
Dir.expects(:chdir).yields
|
129
|
+
@source.expects(:checkout).returns(:local_checkout)
|
130
|
+
|
131
|
+
@strategy.expects(:system).with(:local_checkout)
|
132
|
+
@strategy.expects(:system).with("tar czf 1234567890.tar.gz 1234567890")
|
133
|
+
@strategy.expects(:put).with(:mock_file_contents, "/somewhere/else/1234567890.tar.gz")
|
134
|
+
@strategy.expects(:run).with("cd /u/apps/test/releases && tar xzf /somewhere/else/1234567890.tar.gz && rm /somewhere/else/1234567890.tar.gz")
|
135
|
+
|
136
|
+
mock_file = mock("file")
|
137
|
+
mock_file.expects(:puts).with("154")
|
138
|
+
File.expects(:open).with("/temp/dir/1234567890/REVISION", "w").yields(mock_file)
|
139
|
+
File.expects(:read).with("/temp/dir/1234567890.tar.gz").returns(:mock_file_contents)
|
140
|
+
|
141
|
+
FileUtils.expects(:rm).with("/temp/dir/1234567890.tar.gz")
|
142
|
+
FileUtils.expects(:rm_rf).with("/temp/dir/1234567890")
|
143
|
+
|
144
|
+
@strategy.deploy!
|
145
|
+
end
|
146
|
+
end
|