minmb-capistrano 2.15.4
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/.gitignore +10 -0
- data/.travis.yml +7 -0
- data/CHANGELOG +1170 -0
- data/Gemfile +13 -0
- data/README.md +94 -0
- data/Rakefile +11 -0
- data/bin/cap +4 -0
- data/bin/capify +92 -0
- data/capistrano.gemspec +40 -0
- data/lib/capistrano.rb +5 -0
- data/lib/capistrano/callback.rb +45 -0
- data/lib/capistrano/cli.rb +47 -0
- data/lib/capistrano/cli/execute.rb +85 -0
- data/lib/capistrano/cli/help.rb +125 -0
- data/lib/capistrano/cli/help.txt +81 -0
- data/lib/capistrano/cli/options.rb +243 -0
- data/lib/capistrano/cli/ui.rb +40 -0
- data/lib/capistrano/command.rb +303 -0
- data/lib/capistrano/configuration.rb +57 -0
- data/lib/capistrano/configuration/actions/file_transfer.rb +50 -0
- data/lib/capistrano/configuration/actions/inspect.rb +46 -0
- data/lib/capistrano/configuration/actions/invocation.rb +329 -0
- data/lib/capistrano/configuration/alias_task.rb +26 -0
- data/lib/capistrano/configuration/callbacks.rb +147 -0
- data/lib/capistrano/configuration/connections.rb +237 -0
- data/lib/capistrano/configuration/execution.rb +142 -0
- data/lib/capistrano/configuration/loading.rb +205 -0
- data/lib/capistrano/configuration/log_formatters.rb +75 -0
- data/lib/capistrano/configuration/namespaces.rb +223 -0
- data/lib/capistrano/configuration/roles.rb +77 -0
- data/lib/capistrano/configuration/servers.rb +116 -0
- data/lib/capistrano/configuration/variables.rb +127 -0
- data/lib/capistrano/errors.rb +19 -0
- data/lib/capistrano/ext/multistage.rb +64 -0
- data/lib/capistrano/ext/string.rb +5 -0
- data/lib/capistrano/extensions.rb +57 -0
- data/lib/capistrano/fix_rake_deprecated_dsl.rb +8 -0
- data/lib/capistrano/logger.rb +166 -0
- data/lib/capistrano/processable.rb +57 -0
- data/lib/capistrano/recipes/compat.rb +32 -0
- data/lib/capistrano/recipes/deploy.rb +625 -0
- data/lib/capistrano/recipes/deploy/assets.rb +201 -0
- data/lib/capistrano/recipes/deploy/dependencies.rb +44 -0
- data/lib/capistrano/recipes/deploy/local_dependency.rb +54 -0
- data/lib/capistrano/recipes/deploy/remote_dependency.rb +117 -0
- data/lib/capistrano/recipes/deploy/scm.rb +19 -0
- data/lib/capistrano/recipes/deploy/scm/accurev.rb +169 -0
- data/lib/capistrano/recipes/deploy/scm/base.rb +200 -0
- data/lib/capistrano/recipes/deploy/scm/bzr.rb +86 -0
- data/lib/capistrano/recipes/deploy/scm/cvs.rb +153 -0
- data/lib/capistrano/recipes/deploy/scm/darcs.rb +96 -0
- data/lib/capistrano/recipes/deploy/scm/git.rb +293 -0
- data/lib/capistrano/recipes/deploy/scm/mercurial.rb +137 -0
- data/lib/capistrano/recipes/deploy/scm/none.rb +55 -0
- data/lib/capistrano/recipes/deploy/scm/perforce.rb +152 -0
- data/lib/capistrano/recipes/deploy/scm/subversion.rb +121 -0
- data/lib/capistrano/recipes/deploy/strategy.rb +19 -0
- data/lib/capistrano/recipes/deploy/strategy/base.rb +92 -0
- data/lib/capistrano/recipes/deploy/strategy/checkout.rb +20 -0
- data/lib/capistrano/recipes/deploy/strategy/copy.rb +338 -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 +57 -0
- data/lib/capistrano/recipes/deploy/strategy/unshared_remote_cache.rb +21 -0
- data/lib/capistrano/recipes/standard.rb +37 -0
- data/lib/capistrano/recipes/templates/maintenance.rhtml +53 -0
- data/lib/capistrano/role.rb +102 -0
- data/lib/capistrano/server_definition.rb +56 -0
- data/lib/capistrano/shell.rb +265 -0
- data/lib/capistrano/ssh.rb +95 -0
- data/lib/capistrano/task_definition.rb +77 -0
- data/lib/capistrano/transfer.rb +218 -0
- data/lib/capistrano/version.rb +11 -0
- data/test/cli/execute_test.rb +132 -0
- data/test/cli/help_test.rb +165 -0
- data/test/cli/options_test.rb +329 -0
- data/test/cli/ui_test.rb +28 -0
- data/test/cli_test.rb +17 -0
- data/test/command_test.rb +322 -0
- data/test/configuration/actions/file_transfer_test.rb +61 -0
- data/test/configuration/actions/inspect_test.rb +76 -0
- data/test/configuration/actions/invocation_test.rb +288 -0
- data/test/configuration/alias_task_test.rb +118 -0
- data/test/configuration/callbacks_test.rb +201 -0
- data/test/configuration/connections_test.rb +439 -0
- data/test/configuration/execution_test.rb +175 -0
- data/test/configuration/loading_test.rb +148 -0
- data/test/configuration/namespace_dsl_test.rb +332 -0
- data/test/configuration/roles_test.rb +157 -0
- data/test/configuration/servers_test.rb +183 -0
- data/test/configuration/variables_test.rb +190 -0
- data/test/configuration_test.rb +77 -0
- data/test/deploy/local_dependency_test.rb +76 -0
- data/test/deploy/remote_dependency_test.rb +146 -0
- data/test/deploy/scm/accurev_test.rb +23 -0
- data/test/deploy/scm/base_test.rb +55 -0
- data/test/deploy/scm/bzr_test.rb +51 -0
- data/test/deploy/scm/darcs_test.rb +37 -0
- data/test/deploy/scm/git_test.rb +221 -0
- data/test/deploy/scm/mercurial_test.rb +134 -0
- data/test/deploy/scm/none_test.rb +35 -0
- data/test/deploy/scm/perforce_test.rb +23 -0
- data/test/deploy/scm/subversion_test.rb +40 -0
- data/test/deploy/strategy/copy_test.rb +360 -0
- data/test/extensions_test.rb +69 -0
- data/test/fixtures/cli_integration.rb +5 -0
- data/test/fixtures/config.rb +5 -0
- data/test/fixtures/custom.rb +3 -0
- data/test/logger_formatting_test.rb +149 -0
- data/test/logger_test.rb +134 -0
- data/test/recipes_test.rb +25 -0
- data/test/role_test.rb +11 -0
- data/test/server_definition_test.rb +121 -0
- data/test/shell_test.rb +96 -0
- data/test/ssh_test.rb +113 -0
- data/test/task_definition_test.rb +117 -0
- data/test/transfer_test.rb +168 -0
- data/test/utils.rb +37 -0
- metadata +316 -0
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
require "utils"
|
|
2
|
+
require 'capistrano/recipes/deploy/scm/git'
|
|
3
|
+
|
|
4
|
+
class DeploySCMGitTest < Test::Unit::TestCase
|
|
5
|
+
class TestSCM < Capistrano::Deploy::SCM::Git
|
|
6
|
+
default_command "git"
|
|
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_head
|
|
17
|
+
assert_equal "HEAD", @source.head
|
|
18
|
+
|
|
19
|
+
# With :branch
|
|
20
|
+
@config[:branch] = "master"
|
|
21
|
+
assert_equal "master", @source.head
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def test_origin
|
|
25
|
+
assert_equal "origin", @source.origin
|
|
26
|
+
@config[:remote] = "username"
|
|
27
|
+
assert_equal "username", @source.origin
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def test_checkout
|
|
31
|
+
@config[:repository] = "git@somehost.com:project.git"
|
|
32
|
+
dest = "/var/www"
|
|
33
|
+
rev = 'c2d9e79'
|
|
34
|
+
assert_equal "git clone -q git@somehost.com:project.git /var/www && cd /var/www && git checkout -q -b deploy #{rev}", @source.checkout(rev, dest)
|
|
35
|
+
|
|
36
|
+
# With :scm_command
|
|
37
|
+
git = "/opt/local/bin/git"
|
|
38
|
+
@config[:scm_command] = git
|
|
39
|
+
assert_equal "#{git} clone -q git@somehost.com:project.git /var/www && cd /var/www && #{git} checkout -q -b deploy #{rev}", @source.checkout(rev, dest).gsub(/\s+/, ' ')
|
|
40
|
+
|
|
41
|
+
# with submodules
|
|
42
|
+
@config[:git_enable_submodules] = true
|
|
43
|
+
assert_equal "#{git} clone -q git@somehost.com:project.git /var/www && cd /var/www && #{git} checkout -q -b deploy #{rev} && #{git} submodule -q init && #{git} submodule -q sync && export GIT_RECURSIVE=$([ ! \"`#{git} --version`\" \\< \"git version 1.6.5\" ] && echo --recursive) && #{git} submodule -q update --init $GIT_RECURSIVE", @source.checkout(rev, dest).gsub(/\s+/, ' ')
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def test_checkout_submodules_without_recursive
|
|
47
|
+
@config[:repository] = "git@somehost.com:project.git"
|
|
48
|
+
dest = "/var/www"
|
|
49
|
+
rev = 'c2d9e79'
|
|
50
|
+
@config[:git_enable_submodules] = true
|
|
51
|
+
@config[:git_submodules_recursive] = false
|
|
52
|
+
assert_equal "git clone -q git@somehost.com:project.git /var/www && cd /var/www && git checkout -q -b deploy #{rev} && git submodule -q init && git submodule -q sync && git submodule -q update --init", @source.checkout(rev, dest).gsub(/\s+/, ' ')
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def test_checkout_with_verbose_should_not_use_q_switch
|
|
56
|
+
@config[:repository] = "git@somehost.com:project.git"
|
|
57
|
+
@config[:scm_verbose] = true
|
|
58
|
+
dest = "/var/www"
|
|
59
|
+
rev = 'c2d9e79'
|
|
60
|
+
assert_equal "git clone git@somehost.com:project.git /var/www && cd /var/www && git checkout -b deploy #{rev}", @source.checkout(rev, dest)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def test_checkout_with_verbose_off_should_use_q_switch
|
|
64
|
+
@config[:repository] = "git@somehost.com:project.git"
|
|
65
|
+
@config[:scm_verbose] = false
|
|
66
|
+
dest = "/var/www"
|
|
67
|
+
rev = 'c2d9e79'
|
|
68
|
+
assert_equal "git clone -q git@somehost.com:project.git /var/www && cd /var/www && git checkout -q -b deploy #{rev}", @source.checkout(rev, dest)
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def test_diff
|
|
72
|
+
assert_equal "git diff master", @source.diff('master')
|
|
73
|
+
assert_equal "git diff master..branch", @source.diff('master', 'branch')
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def test_log
|
|
77
|
+
assert_equal "git log master..", @source.log('master')
|
|
78
|
+
assert_equal "git log master..branch", @source.log('master', 'branch')
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def test_query_revision_from_remote
|
|
82
|
+
revision = @source.query_revision('HEAD') do |o|
|
|
83
|
+
assert_equal "git ls-remote . HEAD", o
|
|
84
|
+
"d11006102c07c94e5d54dd0ee63dca825c93ed61\tHEAD"
|
|
85
|
+
end
|
|
86
|
+
assert_equal "d11006102c07c94e5d54dd0ee63dca825c93ed61", revision
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def test_query_revision_falls_back_to_local
|
|
90
|
+
revision = @source.query_revision('d11006') do |o|
|
|
91
|
+
return nil if o == "git ls-remote . d11006"
|
|
92
|
+
assert_equal "git rev-parse --revs-only d11006", o
|
|
93
|
+
"d11006102c07c94e5d54dd0ee63dca825c93ed61"
|
|
94
|
+
end
|
|
95
|
+
assert_equal "d11006102c07c94e5d54dd0ee63dca825c93ed61", revision
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def test_query_revision_has_whitespace
|
|
99
|
+
revision = @source.query_revision('HEAD') do |o|
|
|
100
|
+
assert_equal "git ls-remote . HEAD", o
|
|
101
|
+
"d11006102c07c94e5d54dd0ee63dca825c93ed61\tHEAD\r"
|
|
102
|
+
end
|
|
103
|
+
assert_equal "d11006102c07c94e5d54dd0ee63dca825c93ed61", revision
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
def test_query_revision_deprecation_error
|
|
107
|
+
assert_raise(ArgumentError) do
|
|
108
|
+
revision = @source.query_revision('origin/release') {}
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
def test_command_should_be_backwards_compatible
|
|
113
|
+
# 1.x version of this module used ":git", not ":scm_command"
|
|
114
|
+
@config[:git] = "/srv/bin/git"
|
|
115
|
+
assert_equal "/srv/bin/git", @source.command
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
def test_sync
|
|
119
|
+
dest = "/var/www"
|
|
120
|
+
rev = 'c2d9e79'
|
|
121
|
+
assert_equal "cd #{dest} && git fetch -q origin && git fetch --tags -q origin && git reset -q --hard #{rev} && git clean -q -d -x -f", @source.sync(rev, dest)
|
|
122
|
+
|
|
123
|
+
# With :scm_command
|
|
124
|
+
git = "/opt/local/bin/git"
|
|
125
|
+
@config[:scm_command] = git
|
|
126
|
+
assert_equal "cd #{dest} && #{git} fetch -q origin && #{git} fetch --tags -q origin && #{git} reset -q --hard #{rev} && #{git} clean -q -d -x -f", @source.sync(rev, dest)
|
|
127
|
+
|
|
128
|
+
# with submodules
|
|
129
|
+
@config[:git_enable_submodules] = true
|
|
130
|
+
assert_equal "cd #{dest} && #{git} fetch -q origin && #{git} fetch --tags -q origin && #{git} reset -q --hard #{rev} && #{git} submodule -q init && #{git} submodule -q sync && export GIT_RECURSIVE=$([ ! \"`#{git} --version`\" \\< \"git version 1.6.5\" ] && echo --recursive) && #{git} submodule -q update --init $GIT_RECURSIVE && #{git} clean -q -d -x -f", @source.sync(rev, dest)
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
def test_sync_with_remote
|
|
134
|
+
dest = "/var/www"
|
|
135
|
+
rev = 'c2d9e79'
|
|
136
|
+
remote = "username"
|
|
137
|
+
repository = "git@somehost.com:project.git"
|
|
138
|
+
|
|
139
|
+
@config[:repository] = repository
|
|
140
|
+
@config[:remote] = remote
|
|
141
|
+
|
|
142
|
+
assert_equal "cd #{dest} && git config remote.#{remote}.url #{repository} && git config remote.#{remote}.fetch +refs/heads/*:refs/remotes/#{remote}/* && git fetch -q #{remote} && git fetch --tags -q username && git reset -q --hard #{rev} && git clean -q -d -x -f", @source.sync(rev, dest)
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
def test_shallow_clone
|
|
146
|
+
@config[:repository] = "git@somehost.com:project.git"
|
|
147
|
+
@config[:git_shallow_clone] = 1
|
|
148
|
+
@config[:branch] = nil
|
|
149
|
+
dest = "/var/www"
|
|
150
|
+
rev = 'c2d9e79'
|
|
151
|
+
assert_equal "git clone -q --depth 1 git@somehost.com:project.git /var/www && cd /var/www && git checkout -q -b deploy #{rev}", @source.checkout(rev, dest)
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
def test_shallow_clone_with_branch
|
|
155
|
+
@config[:repository] = "git@somehost.com:project.git"
|
|
156
|
+
@config[:git_shallow_clone] = 1
|
|
157
|
+
@config[:branch] = 'foobar'
|
|
158
|
+
dest = "/var/www"
|
|
159
|
+
rev = 'c2d9e79'
|
|
160
|
+
assert_equal "git clone -q -b foobar --depth 1 git@somehost.com:project.git /var/www && cd /var/www && git checkout -q -b deploy #{rev}", @source.checkout(rev, dest)
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
def test_remote_clone
|
|
164
|
+
@config[:repository] = "git@somehost.com:project.git"
|
|
165
|
+
@config[:remote] = "username"
|
|
166
|
+
dest = "/var/www"
|
|
167
|
+
rev = 'c2d9e79'
|
|
168
|
+
assert_equal "git clone -q -o username git@somehost.com:project.git /var/www && cd /var/www && git checkout -q -b deploy #{rev}", @source.checkout(rev, dest)
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
def test_remote_clone_with_submodules
|
|
172
|
+
@config[:repository] = "git@somehost.com:project.git"
|
|
173
|
+
@config[:remote] = "username"
|
|
174
|
+
@config[:git_enable_submodules] = true
|
|
175
|
+
dest = "/var/www"
|
|
176
|
+
rev = 'c2d9e79'
|
|
177
|
+
assert_equal "git clone -q -o username git@somehost.com:project.git /var/www && cd /var/www && git checkout -q -b deploy #{rev} && git submodule -q init && git submodule -q sync && export GIT_RECURSIVE=$([ ! \"`git --version`\" \\< \"git version 1.6.5\" ] && echo --recursive) && git submodule -q update --init $GIT_RECURSIVE", @source.checkout(rev, dest)
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
# Tests from base_test.rb, makin' sure we didn't break anything up there!
|
|
181
|
+
def test_command_should_default_to_default_command
|
|
182
|
+
assert_equal "git", @source.command
|
|
183
|
+
@source.local { assert_equal "git", @source.command }
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
def test_command_should_use_scm_command_if_available
|
|
187
|
+
@config[:scm_command] = "/opt/local/bin/git"
|
|
188
|
+
assert_equal "/opt/local/bin/git", @source.command
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
def test_command_should_use_scm_command_in_local_mode_if_local_scm_command_not_set
|
|
192
|
+
@config[:scm_command] = "/opt/local/bin/git"
|
|
193
|
+
@source.local { assert_equal "/opt/local/bin/git", @source.command }
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
def test_command_should_use_local_scm_command_in_local_mode_if_local_scm_command_is_set
|
|
197
|
+
@config[:scm_command] = "/opt/local/bin/git"
|
|
198
|
+
@config[:local_scm_command] = "/usr/local/bin/git"
|
|
199
|
+
assert_equal "/opt/local/bin/git", @source.command
|
|
200
|
+
@source.local { assert_equal "/usr/local/bin/git", @source.command }
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
def test_command_should_use_default_if_scm_command_is_default
|
|
204
|
+
@config[:scm_command] = :default
|
|
205
|
+
assert_equal "git", @source.command
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
def test_command_should_use_default_in_local_mode_if_local_scm_command_is_default
|
|
209
|
+
@config[:scm_command] = "/foo/bar/git"
|
|
210
|
+
@config[:local_scm_command] = :default
|
|
211
|
+
@source.local { assert_equal "git", @source.command }
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
def test_local_mode_proxy_should_treat_messages_as_being_in_local_mode
|
|
215
|
+
@config[:scm_command] = "/foo/bar/git"
|
|
216
|
+
@config[:local_scm_command] = :default
|
|
217
|
+
assert_equal "git", @source.local.command
|
|
218
|
+
assert_equal "/foo/bar/git", @source.command
|
|
219
|
+
end
|
|
220
|
+
end
|
|
221
|
+
|
|
@@ -0,0 +1,134 @@
|
|
|
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
|
|
@@ -0,0 +1,35 @@
|
|
|
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
|
|
@@ -0,0 +1,23 @@
|
|
|
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
|
|
@@ -0,0 +1,40 @@
|
|
|
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
|
+
end
|