capistrano 2.15.11 → 3.0.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +17 -8
- data/Gemfile +1 -12
- data/LICENSE.txt +18 -0
- data/README.md +65 -68
- data/Rakefile +4 -10
- data/bin/cap +2 -3
- data/bin/capify +7 -91
- data/capistrano.gemspec +20 -34
- data/lib/Capfile +2 -0
- data/lib/capistrano/application.rb +28 -0
- data/lib/capistrano/bundler.rb +1 -0
- data/lib/capistrano/configuration/question.rb +42 -0
- data/lib/capistrano/configuration/server.rb +24 -0
- data/lib/capistrano/configuration/servers.rb +43 -95
- data/lib/capistrano/configuration.rb +81 -44
- data/lib/capistrano/console.rb +1 -0
- data/lib/capistrano/defaults.rb +11 -0
- data/lib/capistrano/deploy.rb +3 -0
- data/lib/capistrano/dotfile.rb +3 -0
- data/lib/capistrano/dsl/env.rb +57 -0
- data/lib/capistrano/dsl/paths.rb +74 -0
- data/lib/capistrano/dsl/stages.rb +15 -0
- data/lib/capistrano/dsl/task_enhancements.rb +15 -0
- data/lib/capistrano/dsl.rb +38 -0
- data/lib/capistrano/git.rb +1 -0
- data/lib/capistrano/i18n.rb +33 -0
- data/lib/capistrano/install.rb +1 -0
- data/lib/capistrano/setup.rb +17 -0
- data/lib/capistrano/tasks/bundler.rake +13 -0
- data/lib/capistrano/tasks/console.rake +21 -0
- data/lib/capistrano/tasks/deploy.rake +153 -0
- data/lib/capistrano/tasks/framework.rake +45 -0
- data/lib/capistrano/tasks/git.rake +65 -0
- data/lib/capistrano/tasks/install.rake +39 -0
- data/lib/capistrano/templates/Capfile +43 -0
- data/lib/capistrano/templates/deploy.rb.erb +17 -0
- data/lib/capistrano/templates/stage.rb.erb +20 -0
- data/lib/capistrano/version.rb +1 -11
- data/lib/capistrano.rb +9 -3
- data/spec/lib/capistrano/configuration/question_spec.rb +54 -0
- data/spec/lib/capistrano/configuration/server_spec.rb +48 -0
- data/spec/lib/capistrano/configuration/servers_spec.rb +79 -0
- data/spec/lib/capistrano/configuration_spec.rb +80 -0
- data/spec/lib/capistrano/dsl/env_spec.rb +83 -0
- data/spec/lib/capistrano/dsl/paths_spec.rb +69 -0
- data/spec/lib/capistrano/dsl_spec.rb +51 -0
- data/spec/lib/capistrano_spec.rb +8 -0
- data/spec/spec_helper.rb +14 -0
- metadata +89 -215
- data/.travis.yml +0 -9
- data/CHANGELOG +0 -1203
- data/lib/capistrano/callback.rb +0 -45
- data/lib/capistrano/cli/execute.rb +0 -85
- data/lib/capistrano/cli/help.rb +0 -125
- data/lib/capistrano/cli/help.txt +0 -81
- data/lib/capistrano/cli/options.rb +0 -243
- data/lib/capistrano/cli/ui.rb +0 -40
- data/lib/capistrano/cli.rb +0 -47
- data/lib/capistrano/command.rb +0 -303
- data/lib/capistrano/configuration/actions/file_transfer.rb +0 -50
- data/lib/capistrano/configuration/actions/inspect.rb +0 -46
- data/lib/capistrano/configuration/actions/invocation.rb +0 -329
- data/lib/capistrano/configuration/alias_task.rb +0 -26
- data/lib/capistrano/configuration/callbacks.rb +0 -147
- data/lib/capistrano/configuration/connections.rb +0 -237
- data/lib/capistrano/configuration/execution.rb +0 -142
- data/lib/capistrano/configuration/loading.rb +0 -205
- data/lib/capistrano/configuration/log_formatters.rb +0 -75
- data/lib/capistrano/configuration/namespaces.rb +0 -223
- data/lib/capistrano/configuration/roles.rb +0 -83
- data/lib/capistrano/configuration/variables.rb +0 -127
- data/lib/capistrano/errors.rb +0 -19
- data/lib/capistrano/ext/multistage.rb +0 -67
- data/lib/capistrano/ext/string.rb +0 -5
- data/lib/capistrano/extensions.rb +0 -57
- data/lib/capistrano/fix_rake_deprecated_dsl.rb +0 -8
- data/lib/capistrano/logger.rb +0 -166
- data/lib/capistrano/processable.rb +0 -55
- data/lib/capistrano/recipes/compat.rb +0 -32
- data/lib/capistrano/recipes/deploy/assets.rb +0 -202
- data/lib/capistrano/recipes/deploy/dependencies.rb +0 -44
- data/lib/capistrano/recipes/deploy/local_dependency.rb +0 -54
- data/lib/capistrano/recipes/deploy/remote_dependency.rb +0 -117
- data/lib/capistrano/recipes/deploy/scm/accurev.rb +0 -169
- data/lib/capistrano/recipes/deploy/scm/base.rb +0 -200
- data/lib/capistrano/recipes/deploy/scm/bzr.rb +0 -86
- data/lib/capistrano/recipes/deploy/scm/cvs.rb +0 -153
- data/lib/capistrano/recipes/deploy/scm/darcs.rb +0 -96
- data/lib/capistrano/recipes/deploy/scm/git.rb +0 -299
- data/lib/capistrano/recipes/deploy/scm/mercurial.rb +0 -137
- data/lib/capistrano/recipes/deploy/scm/none.rb +0 -55
- data/lib/capistrano/recipes/deploy/scm/perforce.rb +0 -152
- data/lib/capistrano/recipes/deploy/scm/subversion.rb +0 -121
- data/lib/capistrano/recipes/deploy/scm.rb +0 -19
- data/lib/capistrano/recipes/deploy/strategy/base.rb +0 -92
- data/lib/capistrano/recipes/deploy/strategy/checkout.rb +0 -20
- data/lib/capistrano/recipes/deploy/strategy/copy.rb +0 -338
- data/lib/capistrano/recipes/deploy/strategy/export.rb +0 -20
- data/lib/capistrano/recipes/deploy/strategy/remote.rb +0 -52
- data/lib/capistrano/recipes/deploy/strategy/remote_cache.rb +0 -57
- data/lib/capistrano/recipes/deploy/strategy/unshared_remote_cache.rb +0 -21
- data/lib/capistrano/recipes/deploy/strategy.rb +0 -20
- data/lib/capistrano/recipes/deploy.rb +0 -625
- data/lib/capistrano/recipes/standard.rb +0 -37
- data/lib/capistrano/recipes/templates/maintenance.rhtml +0 -53
- data/lib/capistrano/role.rb +0 -102
- data/lib/capistrano/server_definition.rb +0 -56
- data/lib/capistrano/shell.rb +0 -265
- data/lib/capistrano/ssh.rb +0 -95
- data/lib/capistrano/task_definition.rb +0 -77
- data/lib/capistrano/transfer.rb +0 -218
- data/test/cli/execute_test.rb +0 -132
- data/test/cli/help_test.rb +0 -165
- data/test/cli/options_test.rb +0 -329
- data/test/cli/ui_test.rb +0 -28
- data/test/cli_test.rb +0 -17
- data/test/command_test.rb +0 -322
- data/test/configuration/actions/file_transfer_test.rb +0 -61
- data/test/configuration/actions/inspect_test.rb +0 -76
- data/test/configuration/actions/invocation_test.rb +0 -306
- data/test/configuration/alias_task_test.rb +0 -118
- data/test/configuration/callbacks_test.rb +0 -201
- data/test/configuration/connections_test.rb +0 -439
- data/test/configuration/execution_test.rb +0 -175
- data/test/configuration/loading_test.rb +0 -148
- data/test/configuration/namespace_dsl_test.rb +0 -332
- data/test/configuration/roles_test.rb +0 -157
- data/test/configuration/servers_test.rb +0 -183
- data/test/configuration/variables_test.rb +0 -190
- data/test/configuration_test.rb +0 -77
- data/test/deploy/local_dependency_test.rb +0 -76
- data/test/deploy/remote_dependency_test.rb +0 -146
- data/test/deploy/scm/accurev_test.rb +0 -23
- data/test/deploy/scm/base_test.rb +0 -55
- data/test/deploy/scm/bzr_test.rb +0 -51
- data/test/deploy/scm/darcs_test.rb +0 -37
- data/test/deploy/scm/git_test.rb +0 -274
- data/test/deploy/scm/mercurial_test.rb +0 -134
- data/test/deploy/scm/none_test.rb +0 -35
- data/test/deploy/scm/perforce_test.rb +0 -23
- data/test/deploy/scm/subversion_test.rb +0 -68
- data/test/deploy/strategy/copy_test.rb +0 -360
- data/test/extensions_test.rb +0 -69
- data/test/fixtures/cli_integration.rb +0 -5
- data/test/fixtures/config.rb +0 -5
- data/test/fixtures/custom.rb +0 -3
- data/test/logger_formatting_test.rb +0 -149
- data/test/logger_test.rb +0 -134
- data/test/recipes_test.rb +0 -25
- data/test/role_test.rb +0 -11
- data/test/server_definition_test.rb +0 -121
- data/test/shell_test.rb +0 -96
- data/test/ssh_test.rb +0 -113
- data/test/task_definition_test.rb +0 -117
- data/test/transfer_test.rb +0 -168
- data/test/utils.rb +0 -37
- data/test/version_test.rb +0 -11
@@ -1,134 +0,0 @@
|
|
1
|
-
require "utils"
|
2
|
-
require 'capistrano/recipes/deploy/scm/mercurial'
|
3
|
-
|
4
|
-
class DeploySCMMercurialTest < Test::Unit::TestCase
|
5
|
-
class TestSCM < Capistrano::Deploy::SCM::Mercurial
|
6
|
-
default_command "hg"
|
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_head
|
17
|
-
assert_equal "tip", @source.head
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_different_head
|
21
|
-
@config[:branch] = "staging"
|
22
|
-
assert_equal "staging", @source.head
|
23
|
-
end
|
24
|
-
|
25
|
-
def test_checkout
|
26
|
-
@config[:repository] = "http://example.com/project-hg"
|
27
|
-
dest = "/var/www"
|
28
|
-
assert_equal "hg clone --noupdate http://example.com/project-hg /var/www && hg update --repository /var/www --clean 8a8e00b8f11b", @source.checkout('8a8e00b8f11b', dest)
|
29
|
-
end
|
30
|
-
|
31
|
-
def test_diff
|
32
|
-
assert_equal "hg diff --rev tip", @source.diff('tip')
|
33
|
-
assert_equal "hg diff --rev 1 --rev 2", @source.diff('1', '2')
|
34
|
-
end
|
35
|
-
|
36
|
-
def test_log
|
37
|
-
assert_equal "hg log --rev 8a8e00b8f11b", @source.log('8a8e00b8f11b')
|
38
|
-
assert_equal "hg log --rev 0:3", @source.log('0', '3')
|
39
|
-
end
|
40
|
-
|
41
|
-
def test_query_revision
|
42
|
-
assert_equal "hg log -r 8a8e00b8f11b --template \"{node|short}\"", @source.query_revision('8a8e00b8f11b') { |o| o }
|
43
|
-
end
|
44
|
-
|
45
|
-
def test_username_should_be_backwards_compatible
|
46
|
-
# older versions of this module required :scm_user var instead
|
47
|
-
# of the currently preferred :scm_username
|
48
|
-
require 'capistrano/logger'
|
49
|
-
@config[:scm_user] = "fred"
|
50
|
-
text = "user:"
|
51
|
-
assert_equal %("fred"\n), @source.handle_data(mock_state, :test_stream, text)
|
52
|
-
# :scm_username takes priority
|
53
|
-
@config[:scm_username] = "wilma"
|
54
|
-
assert_equal %("wilma"\n), @source.handle_data(mock_state, :test_stream, text)
|
55
|
-
end
|
56
|
-
|
57
|
-
def test_sync
|
58
|
-
dest = "/var/www"
|
59
|
-
assert_equal "hg pull --repository /var/www && hg update --repository /var/www --clean 8a8e00b8f11b", @source.sync('8a8e00b8f11b', dest)
|
60
|
-
|
61
|
-
# With :scm_command
|
62
|
-
@config[:scm_command] = "/opt/local/bin/hg"
|
63
|
-
assert_equal "/opt/local/bin/hg pull --repository /var/www && /opt/local/bin/hg update --repository /var/www --clean 8a8e00b8f11b", @source.sync('8a8e00b8f11b', dest)
|
64
|
-
end
|
65
|
-
|
66
|
-
def test_export
|
67
|
-
dest = "/var/www"
|
68
|
-
assert_raise(NotImplementedError) { @source.export('8a8e00b8f11b', dest) }
|
69
|
-
end
|
70
|
-
|
71
|
-
def test_sends_password_if_set
|
72
|
-
require 'capistrano/logger'
|
73
|
-
text = "password:"
|
74
|
-
@config[:scm_password] = "opensesame"
|
75
|
-
assert_equal %("opensesame"\n), @source.handle_data(mock_state, :test_stream, text)
|
76
|
-
end
|
77
|
-
|
78
|
-
def test_prompts_for_password_if_preferred
|
79
|
-
require 'capistrano/logger'
|
80
|
-
require 'capistrano/cli'
|
81
|
-
Capistrano::CLI.stubs(:password_prompt).with("hg password: ").returns("opensesame")
|
82
|
-
@config[:scm_prefer_prompt] = true
|
83
|
-
text = "password:"
|
84
|
-
assert_equal %("opensesame"\n), @source.handle_data(mock_state, :test_stream, text)
|
85
|
-
end
|
86
|
-
|
87
|
-
|
88
|
-
# Tests from base_test.rb, makin' sure we didn't break anything up there!
|
89
|
-
def test_command_should_default_to_default_command
|
90
|
-
assert_equal "hg", @source.command
|
91
|
-
@source.local { assert_equal "hg", @source.command }
|
92
|
-
end
|
93
|
-
|
94
|
-
def test_command_should_use_scm_command_if_available
|
95
|
-
@config[:scm_command] = "/opt/local/bin/hg"
|
96
|
-
assert_equal "/opt/local/bin/hg", @source.command
|
97
|
-
end
|
98
|
-
|
99
|
-
def test_command_should_use_scm_command_in_local_mode_if_local_scm_command_not_set
|
100
|
-
@config[:scm_command] = "/opt/local/bin/hg"
|
101
|
-
@source.local { assert_equal "/opt/local/bin/hg", @source.command }
|
102
|
-
end
|
103
|
-
|
104
|
-
def test_command_should_use_local_scm_command_in_local_mode_if_local_scm_command_is_set
|
105
|
-
@config[:scm_command] = "/opt/local/bin/hg"
|
106
|
-
@config[:local_scm_command] = "/usr/local/bin/hg"
|
107
|
-
assert_equal "/opt/local/bin/hg", @source.command
|
108
|
-
@source.local { assert_equal "/usr/local/bin/hg", @source.command }
|
109
|
-
end
|
110
|
-
|
111
|
-
def test_command_should_use_default_if_scm_command_is_default
|
112
|
-
@config[:scm_command] = :default
|
113
|
-
assert_equal "hg", @source.command
|
114
|
-
end
|
115
|
-
|
116
|
-
def test_command_should_use_default_in_local_mode_if_local_scm_command_is_default
|
117
|
-
@config[:scm_command] = "/foo/bar/hg"
|
118
|
-
@config[:local_scm_command] = :default
|
119
|
-
@source.local { assert_equal "hg", @source.command }
|
120
|
-
end
|
121
|
-
|
122
|
-
def test_local_mode_proxy_should_treat_messages_as_being_in_local_mode
|
123
|
-
@config[:scm_command] = "/foo/bar/hg"
|
124
|
-
@config[:local_scm_command] = :default
|
125
|
-
assert_equal "hg", @source.local.command
|
126
|
-
assert_equal "/foo/bar/hg", @source.command
|
127
|
-
end
|
128
|
-
|
129
|
-
private
|
130
|
-
|
131
|
-
def mock_state
|
132
|
-
{ :channel => { :host => "abc" } }
|
133
|
-
end
|
134
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
require 'utils'
|
2
|
-
require 'capistrano/recipes/deploy/scm/none'
|
3
|
-
|
4
|
-
class DeploySCMNoneTest < Test::Unit::TestCase
|
5
|
-
class TestSCM < Capistrano::Deploy::SCM::None
|
6
|
-
default_command 'none'
|
7
|
-
end
|
8
|
-
|
9
|
-
def setup
|
10
|
-
@config = {}
|
11
|
-
def @config.exists?(name); key?(name); end
|
12
|
-
@source = TestSCM.new(@config)
|
13
|
-
end
|
14
|
-
|
15
|
-
def test_the_truth
|
16
|
-
assert true
|
17
|
-
end
|
18
|
-
|
19
|
-
def test_checkout_on_linux
|
20
|
-
Capistrano::Deploy::LocalDependency.stubs(:on_windows?).returns(false)
|
21
|
-
@config[:repository] = '.'
|
22
|
-
rev = ''
|
23
|
-
dest = '/var/www'
|
24
|
-
assert_equal "cp -R . /var/www", @source.checkout(rev, dest)
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_checkout_on_windows
|
28
|
-
Capistrano::Deploy::LocalDependency.stubs(:on_windows?).returns(true)
|
29
|
-
@config[:repository] = '.'
|
30
|
-
rev = ''
|
31
|
-
dest = 'c:/Documents and settings/admin/tmp'
|
32
|
-
assert_equal "xcopy . \"c:/Documents and settings/admin/tmp\" /S/I/Y/Q/E", @source.checkout(rev, dest)
|
33
|
-
end
|
34
|
-
|
35
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
require "utils"
|
2
|
-
require 'capistrano/recipes/deploy/scm/perforce'
|
3
|
-
|
4
|
-
class DeploySCMPerforceTest < Test::Unit::TestCase
|
5
|
-
class TestSCM < Capistrano::Deploy::SCM::Perforce
|
6
|
-
default_command "perforce"
|
7
|
-
end
|
8
|
-
def setup
|
9
|
-
@config = { :repository => "." }
|
10
|
-
@source = TestSCM.new(@config)
|
11
|
-
end
|
12
|
-
|
13
|
-
def test_p4_label
|
14
|
-
@config[:p4_label] = "some_p4_label"
|
15
|
-
assert_equal "@some_p4_label", @source.send(:rev_no, 'foo')
|
16
|
-
end
|
17
|
-
|
18
|
-
def test_p4_label_with_symbol
|
19
|
-
@config[:p4_label] = "@some_p4_label"
|
20
|
-
assert_equal "@some_p4_label", @source.send(:rev_no, 'foo')
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|
@@ -1,68 +0,0 @@
|
|
1
|
-
require "utils"
|
2
|
-
require 'capistrano/recipes/deploy/scm/subversion'
|
3
|
-
|
4
|
-
class DeploySCMSubversionTest < Test::Unit::TestCase
|
5
|
-
class TestSCM < Capistrano::Deploy::SCM::Subversion
|
6
|
-
default_command "svn"
|
7
|
-
end
|
8
|
-
|
9
|
-
def setup
|
10
|
-
@config = { :repository => "." }
|
11
|
-
def @config.exists?(name); key?(name); end
|
12
|
-
|
13
|
-
@source = TestSCM.new(@config)
|
14
|
-
end
|
15
|
-
|
16
|
-
def test_query_revision
|
17
|
-
revision = @source.query_revision('HEAD') do |o|
|
18
|
-
assert_equal "svn info . -rHEAD", o
|
19
|
-
%Q{Path: rails_2_3
|
20
|
-
URL: svn+ssh://example.com/var/repos/project/branches/rails_2_3
|
21
|
-
Repository Root: svn+ssh://example.com/var/repos
|
22
|
-
Repository UUID: 2d86388d-c40f-0410-ad6a-a69da6a65d20
|
23
|
-
Revision: 2095
|
24
|
-
Node Kind: directory
|
25
|
-
Last Changed Author: sw
|
26
|
-
Last Changed Rev: 2064
|
27
|
-
Last Changed Date: 2009-03-11 11:04:25 -0700 (Wed, 11 Mar 2009)
|
28
|
-
}
|
29
|
-
end
|
30
|
-
assert_equal 2095, revision
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_sync
|
34
|
-
@config[:repository] = "http://svn.github.com/capistrano/capistrano.git"
|
35
|
-
rev = '602'
|
36
|
-
dest = "/var/www"
|
37
|
-
assert_equal "svn switch -q -r602 http://svn.github.com/capistrano/capistrano.git /var/www", @source.sync(rev, dest)
|
38
|
-
end
|
39
|
-
|
40
|
-
def test_sends_password_if_set
|
41
|
-
require 'capistrano/logger'
|
42
|
-
text = "password:"
|
43
|
-
@config[:scm_password] = "opensesame"
|
44
|
-
assert_equal %("opensesame"\n), @source.handle_data(mock_state, :test_stream, text)
|
45
|
-
end
|
46
|
-
|
47
|
-
def test_prompt_password
|
48
|
-
require 'capistrano/logger'
|
49
|
-
require 'capistrano/cli'
|
50
|
-
Capistrano::CLI.stubs(:password_prompt).returns("opensesame")
|
51
|
-
|
52
|
-
text = 'password:'
|
53
|
-
assert_equal %("opensesame"\n), @source.handle_data(mock_state, :test_stream, text)
|
54
|
-
end
|
55
|
-
|
56
|
-
def test_sends_passphrase
|
57
|
-
require 'capistrano/logger'
|
58
|
-
text = 'passphrase:'
|
59
|
-
@config[:scm_passphrase] = "opensesame"
|
60
|
-
assert_equal %("opensesame"\n), @source.handle_data(mock_state, :test_stream, text)
|
61
|
-
end
|
62
|
-
|
63
|
-
private
|
64
|
-
|
65
|
-
def mock_state
|
66
|
-
{ :channel => { :host => "abc" } }
|
67
|
-
end
|
68
|
-
end
|
@@ -1,360 +0,0 @@
|
|
1
|
-
require "utils"
|
2
|
-
require 'capistrano/logger'
|
3
|
-
require 'capistrano/recipes/deploy/strategy/copy'
|
4
|
-
require 'stringio'
|
5
|
-
|
6
|
-
class DeployStrategyCopyTest < Test::Unit::TestCase
|
7
|
-
def setup
|
8
|
-
@config = { :application => "captest",
|
9
|
-
:releases_path => "/u/apps/test/releases",
|
10
|
-
:release_path => "/u/apps/test/releases/1234567890",
|
11
|
-
:real_revision => "154" }
|
12
|
-
@config.stubs(:logger).returns(stub_everything)
|
13
|
-
|
14
|
-
@source = mock("source")
|
15
|
-
@config.stubs(:source).returns(@source)
|
16
|
-
@strategy = Capistrano::Deploy::Strategy::Copy.new(@config)
|
17
|
-
end
|
18
|
-
|
19
|
-
def test_deploy_with_defaults_should_use_remote_gtar
|
20
|
-
@config[:copy_remote_tar] = 'gtar'
|
21
|
-
|
22
|
-
Dir.expects(:tmpdir).returns("/temp/dir")
|
23
|
-
@source.expects(:checkout).with("154", "/temp/dir/1234567890").returns(:local_checkout)
|
24
|
-
@strategy.expects(:system).with(:local_checkout)
|
25
|
-
|
26
|
-
Dir.expects(:chdir).with("/temp/dir").yields
|
27
|
-
@strategy.expects(:system).with("tar czf 1234567890.tar.gz 1234567890")
|
28
|
-
@strategy.expects(:upload).with("/temp/dir/1234567890.tar.gz", "/tmp/1234567890.tar.gz")
|
29
|
-
@strategy.expects(:run).with("cd /u/apps/test/releases && gtar xzf /tmp/1234567890.tar.gz && rm /tmp/1234567890.tar.gz")
|
30
|
-
|
31
|
-
mock_file = mock("file")
|
32
|
-
mock_file.expects(:puts).with("154")
|
33
|
-
File.expects(:open).with("/temp/dir/1234567890/REVISION", "w").yields(mock_file)
|
34
|
-
|
35
|
-
FileUtils.expects(:rm).with("/temp/dir/1234567890.tar.gz")
|
36
|
-
FileUtils.expects(:rm_rf).with("/temp/dir/1234567890")
|
37
|
-
|
38
|
-
@strategy.deploy!
|
39
|
-
end
|
40
|
-
|
41
|
-
def test_deploy_with_defaults_should_use_local_gtar
|
42
|
-
@config[:copy_local_tar] = 'gtar'
|
43
|
-
|
44
|
-
Dir.expects(:tmpdir).returns("/temp/dir")
|
45
|
-
@source.expects(:checkout).with("154", "/temp/dir/1234567890").returns(:local_checkout)
|
46
|
-
@strategy.expects(:system).with(:local_checkout)
|
47
|
-
|
48
|
-
Dir.expects(:chdir).with("/temp/dir").yields
|
49
|
-
@strategy.expects(:system).with("gtar czf 1234567890.tar.gz 1234567890")
|
50
|
-
@strategy.expects(:upload).with("/temp/dir/1234567890.tar.gz", "/tmp/1234567890.tar.gz")
|
51
|
-
@strategy.expects(:run).with("cd /u/apps/test/releases && tar xzf /tmp/1234567890.tar.gz && rm /tmp/1234567890.tar.gz")
|
52
|
-
|
53
|
-
mock_file = mock("file")
|
54
|
-
mock_file.expects(:puts).with("154")
|
55
|
-
File.expects(:open).with("/temp/dir/1234567890/REVISION", "w").yields(mock_file)
|
56
|
-
|
57
|
-
FileUtils.expects(:rm).with("/temp/dir/1234567890.tar.gz")
|
58
|
-
FileUtils.expects(:rm_rf).with("/temp/dir/1234567890")
|
59
|
-
|
60
|
-
@strategy.deploy!
|
61
|
-
end
|
62
|
-
|
63
|
-
def test_deploy_with_defaults_should_use_tar_gz_and_checkout
|
64
|
-
Dir.expects(:tmpdir).returns("/temp/dir")
|
65
|
-
@source.expects(:checkout).with("154", "/temp/dir/1234567890").returns(:local_checkout)
|
66
|
-
@strategy.expects(:system).with(:local_checkout)
|
67
|
-
|
68
|
-
prepare_standard_compress_and_copy!
|
69
|
-
@strategy.deploy!
|
70
|
-
end
|
71
|
-
|
72
|
-
def test_deploy_with_exclusions_should_remove_patterns_from_destination
|
73
|
-
@config[:copy_exclude] = ".git"
|
74
|
-
Dir.expects(:tmpdir).returns("/temp/dir")
|
75
|
-
@source.expects(:checkout).with("154", "/temp/dir/1234567890").returns(:local_checkout)
|
76
|
-
@strategy.expects(:system).with(:local_checkout)
|
77
|
-
Dir.expects(:glob).with("/temp/dir/1234567890/.git", File::FNM_DOTMATCH).returns(%w(/temp/dir/1234567890/.git))
|
78
|
-
|
79
|
-
FileUtils.expects(:rm_rf).with(%w(/temp/dir/1234567890/.git))
|
80
|
-
prepare_standard_compress_and_copy!
|
81
|
-
@strategy.deploy!
|
82
|
-
end
|
83
|
-
|
84
|
-
def test_deploy_with_exclusions_should_remove_glob_patterns_from_destination
|
85
|
-
@config[:copy_exclude] = ".gi*"
|
86
|
-
Dir.expects(:tmpdir).returns("/temp/dir")
|
87
|
-
@source.expects(:checkout).with("154", "/temp/dir/1234567890").returns(:local_checkout)
|
88
|
-
@strategy.expects(:system).with(:local_checkout)
|
89
|
-
Dir.expects(:glob).with("/temp/dir/1234567890/.gi*", File::FNM_DOTMATCH).returns(%w(/temp/dir/1234567890/.git))
|
90
|
-
|
91
|
-
FileUtils.expects(:rm_rf).with(%w(/temp/dir/1234567890/.git))
|
92
|
-
prepare_standard_compress_and_copy!
|
93
|
-
@strategy.deploy!
|
94
|
-
end
|
95
|
-
|
96
|
-
def test_deploy_with_export_should_use_tar_gz_and_export
|
97
|
-
Dir.expects(:tmpdir).returns("/temp/dir")
|
98
|
-
@config[:copy_strategy] = :export
|
99
|
-
@source.expects(:export).with("154", "/temp/dir/1234567890").returns(:local_export)
|
100
|
-
@strategy.expects(:system).with(:local_export)
|
101
|
-
|
102
|
-
prepare_standard_compress_and_copy!
|
103
|
-
@strategy.deploy!
|
104
|
-
end
|
105
|
-
|
106
|
-
def test_deploy_with_zip_should_use_zip_and_checkout
|
107
|
-
Dir.expects(:tmpdir).returns("/temp/dir")
|
108
|
-
Dir.expects(:chdir).with("/temp/dir").yields
|
109
|
-
@config[:copy_compression] = :zip
|
110
|
-
@source.expects(:checkout).with("154", "/temp/dir/1234567890").returns(:local_checkout)
|
111
|
-
|
112
|
-
@strategy.expects(:system).with(:local_checkout)
|
113
|
-
@strategy.expects(:system).with("zip -qyr 1234567890.zip 1234567890")
|
114
|
-
@strategy.expects(:upload).with("/temp/dir/1234567890.zip", "/tmp/1234567890.zip")
|
115
|
-
@strategy.expects(:run).with("cd /u/apps/test/releases && unzip -q /tmp/1234567890.zip && rm /tmp/1234567890.zip")
|
116
|
-
|
117
|
-
mock_file = mock("file")
|
118
|
-
mock_file.expects(:puts).with("154")
|
119
|
-
File.expects(:open).with("/temp/dir/1234567890/REVISION", "w").yields(mock_file)
|
120
|
-
|
121
|
-
FileUtils.expects(:rm).with("/temp/dir/1234567890.zip")
|
122
|
-
FileUtils.expects(:rm_rf).with("/temp/dir/1234567890")
|
123
|
-
|
124
|
-
@strategy.deploy!
|
125
|
-
end
|
126
|
-
|
127
|
-
def test_deploy_with_bzip2_should_use_bz2_and_checkout
|
128
|
-
Dir.expects(:tmpdir).returns("/temp/dir")
|
129
|
-
Dir.expects(:chdir).with("/temp/dir").yields
|
130
|
-
@config[:copy_compression] = :bzip2
|
131
|
-
@source.expects(:checkout).with("154", "/temp/dir/1234567890").returns(:local_checkout)
|
132
|
-
|
133
|
-
@strategy.expects(:system).with(:local_checkout)
|
134
|
-
@strategy.expects(:system).with("tar cjf 1234567890.tar.bz2 1234567890")
|
135
|
-
@strategy.expects(:upload).with("/temp/dir/1234567890.tar.bz2", "/tmp/1234567890.tar.bz2")
|
136
|
-
@strategy.expects(:run).with("cd /u/apps/test/releases && tar xjf /tmp/1234567890.tar.bz2 && rm /tmp/1234567890.tar.bz2")
|
137
|
-
|
138
|
-
mock_file = mock("file")
|
139
|
-
mock_file.expects(:puts).with("154")
|
140
|
-
File.expects(:open).with("/temp/dir/1234567890/REVISION", "w").yields(mock_file)
|
141
|
-
|
142
|
-
FileUtils.expects(:rm).with("/temp/dir/1234567890.tar.bz2")
|
143
|
-
FileUtils.expects(:rm_rf).with("/temp/dir/1234567890")
|
144
|
-
|
145
|
-
@strategy.deploy!
|
146
|
-
end
|
147
|
-
|
148
|
-
def test_deploy_with_unknown_compression_type_should_error
|
149
|
-
@config[:copy_compression] = :bogus
|
150
|
-
Dir.expects(:tmpdir).returns("/temp/dir")
|
151
|
-
@source.expects(:checkout).with("154", "/temp/dir/1234567890").returns(:local_checkout)
|
152
|
-
@strategy.stubs(:system)
|
153
|
-
File.stubs(:open)
|
154
|
-
|
155
|
-
assert_raises(ArgumentError) { @strategy.deploy! }
|
156
|
-
end
|
157
|
-
|
158
|
-
def test_deploy_with_custom_copy_dir_should_use_that_as_tmpdir
|
159
|
-
Dir.expects(:tmpdir).never
|
160
|
-
Dir.expects(:chdir).with("/other/path").yields
|
161
|
-
@config[:copy_dir] = "/other/path"
|
162
|
-
@source.expects(:checkout).with("154", "/other/path/1234567890").returns(:local_checkout)
|
163
|
-
|
164
|
-
@strategy.expects(:system).with(:local_checkout)
|
165
|
-
@strategy.expects(:system).with("tar czf 1234567890.tar.gz 1234567890")
|
166
|
-
@strategy.expects(:upload).with("/other/path/1234567890.tar.gz", "/tmp/1234567890.tar.gz")
|
167
|
-
@strategy.expects(:run).with("cd /u/apps/test/releases && tar xzf /tmp/1234567890.tar.gz && rm /tmp/1234567890.tar.gz")
|
168
|
-
|
169
|
-
mock_file = mock("file")
|
170
|
-
mock_file.expects(:puts).with("154")
|
171
|
-
File.expects(:open).with("/other/path/1234567890/REVISION", "w").yields(mock_file)
|
172
|
-
|
173
|
-
FileUtils.expects(:rm).with("/other/path/1234567890.tar.gz")
|
174
|
-
FileUtils.expects(:rm_rf).with("/other/path/1234567890")
|
175
|
-
|
176
|
-
@strategy.deploy!
|
177
|
-
end
|
178
|
-
|
179
|
-
def test_deploy_with_copy_remote_dir_should_copy_to_that_dir
|
180
|
-
@config[:copy_remote_dir] = "/somewhere/else"
|
181
|
-
Dir.expects(:tmpdir).returns("/temp/dir")
|
182
|
-
Dir.expects(:chdir).yields
|
183
|
-
@source.expects(:checkout).returns(:local_checkout)
|
184
|
-
|
185
|
-
@strategy.expects(:system).with(:local_checkout)
|
186
|
-
@strategy.expects(:system).with("tar czf 1234567890.tar.gz 1234567890")
|
187
|
-
@strategy.expects(:upload).with("/temp/dir/1234567890.tar.gz", "/somewhere/else/1234567890.tar.gz")
|
188
|
-
@strategy.expects(:run).with("cd /u/apps/test/releases && tar xzf /somewhere/else/1234567890.tar.gz && rm /somewhere/else/1234567890.tar.gz")
|
189
|
-
|
190
|
-
mock_file = mock("file")
|
191
|
-
mock_file.expects(:puts).with("154")
|
192
|
-
File.expects(:open).with("/temp/dir/1234567890/REVISION", "w").yields(mock_file)
|
193
|
-
|
194
|
-
FileUtils.expects(:rm).with("/temp/dir/1234567890.tar.gz")
|
195
|
-
FileUtils.expects(:rm_rf).with("/temp/dir/1234567890")
|
196
|
-
|
197
|
-
@strategy.deploy!
|
198
|
-
end
|
199
|
-
|
200
|
-
def test_deploy_with_copy_via_should_use_the_given_transfer_method
|
201
|
-
@config[:copy_via] = :scp
|
202
|
-
Dir.expects(:tmpdir).returns("/temp/dir")
|
203
|
-
Dir.expects(:chdir).yields
|
204
|
-
@source.expects(:checkout).returns(:local_checkout)
|
205
|
-
|
206
|
-
@strategy.expects(:system).with(:local_checkout)
|
207
|
-
@strategy.expects(:system).with("tar czf 1234567890.tar.gz 1234567890")
|
208
|
-
@strategy.expects(:upload).with("/temp/dir/1234567890.tar.gz", "/tmp/1234567890.tar.gz", {:via => :scp})
|
209
|
-
@strategy.expects(:run).with("cd /u/apps/test/releases && tar xzf /tmp/1234567890.tar.gz && rm /tmp/1234567890.tar.gz")
|
210
|
-
|
211
|
-
mock_file = mock("file")
|
212
|
-
mock_file.expects(:puts).with("154")
|
213
|
-
File.expects(:open).with("/temp/dir/1234567890/REVISION", "w").yields(mock_file)
|
214
|
-
|
215
|
-
FileUtils.expects(:rm).with("/temp/dir/1234567890.tar.gz")
|
216
|
-
FileUtils.expects(:rm_rf).with("/temp/dir/1234567890")
|
217
|
-
|
218
|
-
@strategy.deploy!
|
219
|
-
end
|
220
|
-
|
221
|
-
def test_with_copy_cache_should_checkout_to_cache_if_cache_does_not_exist_and_then_copy
|
222
|
-
@config[:copy_cache] = true
|
223
|
-
|
224
|
-
Dir.stubs(:tmpdir).returns("/temp/dir")
|
225
|
-
File.expects(:exist?).with("/temp/dir/captest").returns(false)
|
226
|
-
Dir.expects(:chdir).with("/temp/dir/captest").yields
|
227
|
-
|
228
|
-
@source.expects(:checkout).with("154", "/temp/dir/captest").returns(:local_checkout)
|
229
|
-
@strategy.expects(:system).with(:local_checkout)
|
230
|
-
|
231
|
-
FileUtils.expects(:mkdir_p).with("/temp/dir/1234567890")
|
232
|
-
|
233
|
-
prepare_directory_tree!("/temp/dir/captest")
|
234
|
-
|
235
|
-
prepare_standard_compress_and_copy!
|
236
|
-
@strategy.deploy!
|
237
|
-
end
|
238
|
-
|
239
|
-
def test_with_copy_cache_should_update_cache_if_cache_exists_and_then_copy
|
240
|
-
@config[:copy_cache] = true
|
241
|
-
|
242
|
-
Dir.stubs(:tmpdir).returns("/temp/dir")
|
243
|
-
File.expects(:exist?).with("/temp/dir/captest").returns(true)
|
244
|
-
Dir.expects(:chdir).with("/temp/dir/captest").yields
|
245
|
-
|
246
|
-
@source.expects(:sync).with("154", "/temp/dir/captest").returns(:local_sync)
|
247
|
-
@strategy.expects(:system).with(:local_sync)
|
248
|
-
|
249
|
-
FileUtils.expects(:mkdir_p).with("/temp/dir/1234567890")
|
250
|
-
|
251
|
-
prepare_directory_tree!("/temp/dir/captest")
|
252
|
-
|
253
|
-
prepare_standard_compress_and_copy!
|
254
|
-
@strategy.deploy!
|
255
|
-
end
|
256
|
-
|
257
|
-
def test_with_copy_cache_with_custom_absolute_cache_dir_path_should_use_specified_cache_dir
|
258
|
-
@config[:copy_cache] = "/u/caches/captest"
|
259
|
-
|
260
|
-
Dir.stubs(:tmpdir).returns("/temp/dir")
|
261
|
-
File.expects(:exist?).with("/u/caches/captest").returns(true)
|
262
|
-
Dir.expects(:chdir).with("/u/caches/captest").yields
|
263
|
-
|
264
|
-
@source.expects(:sync).with("154", "/u/caches/captest").returns(:local_sync)
|
265
|
-
@strategy.expects(:system).with(:local_sync)
|
266
|
-
|
267
|
-
FileUtils.expects(:mkdir_p).with("/temp/dir/1234567890")
|
268
|
-
|
269
|
-
prepare_directory_tree!("/u/caches/captest")
|
270
|
-
|
271
|
-
prepare_standard_compress_and_copy!
|
272
|
-
@strategy.deploy!
|
273
|
-
end
|
274
|
-
|
275
|
-
def test_with_copy_cache_with_custom_relative_cache_dir_path_should_use_specified_cache_dir
|
276
|
-
@config[:copy_cache] = "caches/captest"
|
277
|
-
|
278
|
-
Dir.stubs(:pwd).returns("/u")
|
279
|
-
Dir.stubs(:tmpdir).returns("/temp/dir")
|
280
|
-
File.expects(:exist?).with("/u/caches/captest").returns(true)
|
281
|
-
Dir.expects(:chdir).with("/u/caches/captest").yields
|
282
|
-
|
283
|
-
@source.expects(:sync).with("154", "/u/caches/captest").returns(:local_sync)
|
284
|
-
@strategy.expects(:system).with(:local_sync)
|
285
|
-
|
286
|
-
FileUtils.expects(:mkdir_p).with("/temp/dir/1234567890")
|
287
|
-
|
288
|
-
prepare_directory_tree!("/u/caches/captest")
|
289
|
-
|
290
|
-
prepare_standard_compress_and_copy!
|
291
|
-
@strategy.deploy!
|
292
|
-
end
|
293
|
-
|
294
|
-
def test_with_copy_cache_with_excludes_should_not_copy_excluded_files
|
295
|
-
@config[:copy_cache] = true
|
296
|
-
@config[:copy_exclude] = "*/bar.txt"
|
297
|
-
|
298
|
-
Dir.stubs(:tmpdir).returns("/temp/dir")
|
299
|
-
File.expects(:exist?).with("/temp/dir/captest").returns(true)
|
300
|
-
Dir.expects(:chdir).with("/temp/dir/captest").yields
|
301
|
-
|
302
|
-
@source.expects(:sync).with("154", "/temp/dir/captest").returns(:local_sync)
|
303
|
-
@strategy.expects(:system).with(:local_sync)
|
304
|
-
|
305
|
-
FileUtils.expects(:mkdir_p).with("/temp/dir/1234567890")
|
306
|
-
|
307
|
-
prepare_directory_tree!("/temp/dir/captest", true)
|
308
|
-
|
309
|
-
prepare_standard_compress_and_copy!
|
310
|
-
@strategy.deploy!
|
311
|
-
end
|
312
|
-
|
313
|
-
def test_with_build_script_should_run_script
|
314
|
-
@config[:build_script] = "mkdir bin"
|
315
|
-
|
316
|
-
Dir.expects(:tmpdir).returns("/temp/dir")
|
317
|
-
@source.expects(:checkout).with("154", "/temp/dir/1234567890").returns(:local_checkout)
|
318
|
-
@strategy.expects(:system).with(:local_checkout)
|
319
|
-
|
320
|
-
Dir.expects(:chdir).with("/temp/dir/1234567890").yields
|
321
|
-
@strategy.expects(:system).with("mkdir bin")
|
322
|
-
|
323
|
-
prepare_standard_compress_and_copy!
|
324
|
-
@strategy.deploy!
|
325
|
-
end
|
326
|
-
|
327
|
-
private
|
328
|
-
|
329
|
-
def prepare_directory_tree!(cache, exclude=false)
|
330
|
-
Dir.expects(:glob).with("*", File::FNM_DOTMATCH).returns([".", "..", "app", "app{1}", "foo.txt"])
|
331
|
-
File.expects(:ftype).with("app").returns("directory")
|
332
|
-
File.expects(:ftype).with("app{1}").returns("directory")
|
333
|
-
FileUtils.expects(:mkdir).with("/temp/dir/1234567890/app")
|
334
|
-
FileUtils.expects(:mkdir).with("/temp/dir/1234567890/app{1}")
|
335
|
-
File.expects(:ftype).with("foo.txt").returns("file")
|
336
|
-
FileUtils.expects(:ln).with("foo.txt", "/temp/dir/1234567890/foo.txt")
|
337
|
-
|
338
|
-
Dir.expects(:glob).with("app/*", File::FNM_DOTMATCH).returns(["app/.", "app/..", "app/bar.txt"])
|
339
|
-
Dir.expects(:glob).with("app\\{1\\}/*", File::FNM_DOTMATCH).returns(["app{1}/.", "app{1}/.."])
|
340
|
-
|
341
|
-
unless exclude
|
342
|
-
File.expects(:ftype).with("app/bar.txt").returns("file")
|
343
|
-
FileUtils.expects(:ln).with("app/bar.txt", "/temp/dir/1234567890/app/bar.txt")
|
344
|
-
end
|
345
|
-
end
|
346
|
-
|
347
|
-
def prepare_standard_compress_and_copy!
|
348
|
-
Dir.expects(:chdir).with("/temp/dir").yields
|
349
|
-
@strategy.expects(:system).with("tar czf 1234567890.tar.gz 1234567890")
|
350
|
-
@strategy.expects(:upload).with("/temp/dir/1234567890.tar.gz", "/tmp/1234567890.tar.gz")
|
351
|
-
@strategy.expects(:run).with("cd /u/apps/test/releases && tar xzf /tmp/1234567890.tar.gz && rm /tmp/1234567890.tar.gz")
|
352
|
-
|
353
|
-
mock_file = mock("file")
|
354
|
-
mock_file.expects(:puts).with("154")
|
355
|
-
File.expects(:open).with("/temp/dir/1234567890/REVISION", "w").yields(mock_file)
|
356
|
-
|
357
|
-
FileUtils.expects(:rm).with("/temp/dir/1234567890.tar.gz")
|
358
|
-
FileUtils.expects(:rm_rf).with("/temp/dir/1234567890")
|
359
|
-
end
|
360
|
-
end
|