minestrone 0.0.1

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.
Files changed (96) hide show
  1. checksums.yaml +7 -0
  2. data/.github/workflows/main.yml +32 -0
  3. data/.gitignore +5 -0
  4. data/Gemfile +10 -0
  5. data/LICENSE.txt +22 -0
  6. data/README.md +35 -0
  7. data/Rakefile +10 -0
  8. data/bin/capify +89 -0
  9. data/bin/min +5 -0
  10. data/docs/lib-codebase-map.md +162 -0
  11. data/docs/lib-dependency-graph.svg +129 -0
  12. data/lib/minestrone/callback.rb +45 -0
  13. data/lib/minestrone/cli/help.rb +131 -0
  14. data/lib/minestrone/cli/help.txt +72 -0
  15. data/lib/minestrone/cli/options.rb +232 -0
  16. data/lib/minestrone/cli.rb +159 -0
  17. data/lib/minestrone/command.rb +177 -0
  18. data/lib/minestrone/configuration/actions/file_transfer.rb +53 -0
  19. data/lib/minestrone/configuration/actions/inspect.rb +46 -0
  20. data/lib/minestrone/configuration/actions/invocation.rb +202 -0
  21. data/lib/minestrone/configuration/alias_task.rb +29 -0
  22. data/lib/minestrone/configuration/callbacks.rb +129 -0
  23. data/lib/minestrone/configuration/connections.rb +66 -0
  24. data/lib/minestrone/configuration/execution.rb +139 -0
  25. data/lib/minestrone/configuration/loading.rb +207 -0
  26. data/lib/minestrone/configuration/log_formatters.rb +75 -0
  27. data/lib/minestrone/configuration/namespaces.rb +225 -0
  28. data/lib/minestrone/configuration/servers.rb +70 -0
  29. data/lib/minestrone/configuration/variables.rb +115 -0
  30. data/lib/minestrone/configuration.rb +69 -0
  31. data/lib/minestrone/errors.rb +17 -0
  32. data/lib/minestrone/ext/string.rb +7 -0
  33. data/lib/minestrone/extensions.rb +56 -0
  34. data/lib/minestrone/logger.rb +171 -0
  35. data/lib/minestrone/processable.rb +50 -0
  36. data/lib/minestrone/recipes/deploy/assets.rb +194 -0
  37. data/lib/minestrone/recipes/deploy/bundler.rb +81 -0
  38. data/lib/minestrone/recipes/deploy/dependencies.rb +44 -0
  39. data/lib/minestrone/recipes/deploy/local_dependency.rb +45 -0
  40. data/lib/minestrone/recipes/deploy/remote_dependency.rb +119 -0
  41. data/lib/minestrone/recipes/deploy/scm/base.rb +204 -0
  42. data/lib/minestrone/recipes/deploy/scm/git.rb +284 -0
  43. data/lib/minestrone/recipes/deploy/scm/none.rb +54 -0
  44. data/lib/minestrone/recipes/deploy/scm.rb +22 -0
  45. data/lib/minestrone/recipes/deploy/strategy/base.rb +87 -0
  46. data/lib/minestrone/recipes/deploy/strategy/copy.rb +353 -0
  47. data/lib/minestrone/recipes/deploy/strategy/remote_cache.rb +80 -0
  48. data/lib/minestrone/recipes/deploy/strategy.rb +22 -0
  49. data/lib/minestrone/recipes/deploy.rb +639 -0
  50. data/lib/minestrone/recipes/standard.rb +23 -0
  51. data/lib/minestrone/recipes/templates/maintenance.rhtml +53 -0
  52. data/lib/minestrone/server_definition.rb +56 -0
  53. data/lib/minestrone/ssh.rb +81 -0
  54. data/lib/minestrone/task_definition.rb +82 -0
  55. data/lib/minestrone/transfer.rb +205 -0
  56. data/lib/minestrone/version.rb +11 -0
  57. data/lib/minestrone.rb +3 -0
  58. data/minestrone.gemspec +32 -0
  59. data/test/cli/execute_test.rb +130 -0
  60. data/test/cli/help_test.rb +178 -0
  61. data/test/cli/options_test.rb +315 -0
  62. data/test/cli/ui_test.rb +26 -0
  63. data/test/cli_test.rb +17 -0
  64. data/test/command_test.rb +305 -0
  65. data/test/configuration/actions/file_transfer_test.rb +61 -0
  66. data/test/configuration/actions/inspect_test.rb +76 -0
  67. data/test/configuration/actions/invocation_test.rb +258 -0
  68. data/test/configuration/alias_task_test.rb +110 -0
  69. data/test/configuration/callbacks_test.rb +201 -0
  70. data/test/configuration/connections_test.rb +192 -0
  71. data/test/configuration/execution_test.rb +176 -0
  72. data/test/configuration/loading_test.rb +149 -0
  73. data/test/configuration/namespace_dsl_test.rb +325 -0
  74. data/test/configuration/servers_test.rb +100 -0
  75. data/test/configuration/variables_test.rb +191 -0
  76. data/test/configuration_test.rb +77 -0
  77. data/test/deploy/local_dependency_test.rb +61 -0
  78. data/test/deploy/remote_dependency_test.rb +146 -0
  79. data/test/deploy/scm/base_test.rb +55 -0
  80. data/test/deploy/scm/git_test.rb +260 -0
  81. data/test/deploy/scm/none_test.rb +26 -0
  82. data/test/deploy/strategy/copy_test.rb +360 -0
  83. data/test/extensions_test.rb +69 -0
  84. data/test/fixtures/cli_integration.rb +5 -0
  85. data/test/fixtures/config.rb +4 -0
  86. data/test/fixtures/custom.rb +3 -0
  87. data/test/logger_formatting_test.rb +149 -0
  88. data/test/logger_test.rb +134 -0
  89. data/test/recipes_test.rb +26 -0
  90. data/test/server_definition_test.rb +121 -0
  91. data/test/ssh_test.rb +99 -0
  92. data/test/task_definition_test.rb +117 -0
  93. data/test/transfer_test.rb +172 -0
  94. data/test/utils.rb +28 -0
  95. data/test/version_test.rb +11 -0
  96. metadata +258 -0
@@ -0,0 +1,191 @@
1
+ require "utils"
2
+ require 'minestrone/configuration/variables'
3
+
4
+ class ConfigurationVariablesTest < Test::Unit::TestCase
5
+ class MockConfig
6
+ attr_reader :original_initialize_called
7
+
8
+ def initialize
9
+ @original_initialize_called = true
10
+ initialize_variables
11
+ end
12
+
13
+ include Minestrone::Configuration::Variables
14
+ end
15
+
16
+ def setup
17
+ MockConfig.any_instance.stubs(:logger).returns(stub_everything)
18
+ @config = MockConfig.new
19
+ end
20
+
21
+ def test_initialize_should_initialize_variables_hash
22
+ assert @config.original_initialize_called
23
+ assert_equal({:ssh_options => {}, :logger => @config.logger}, @config.variables)
24
+ end
25
+
26
+ def test_set_should_add_variable_to_hash
27
+ @config.set :sample, :value
28
+ assert_equal :value, @config.variables[:sample]
29
+ end
30
+
31
+ def test_set_should_convert_variable_name_to_symbol
32
+ @config.set "sample", :value
33
+ assert_equal :value, @config.variables[:sample]
34
+ end
35
+
36
+ def test_set_should_be_aliased_to_square_brackets
37
+ @config[:sample] = :value
38
+ assert_equal :value, @config.variables[:sample]
39
+ end
40
+
41
+ def test_variables_should_be_accessible_as_read_accessors
42
+ @config[:sample] = :value
43
+ assert_equal :value, @config.sample
44
+ end
45
+
46
+ def test_method_missing_should_raise_error_if_no_variable_matches
47
+ assert_raises(NoMethodError) do
48
+ @config.sample
49
+ end
50
+ end
51
+
52
+ def test_respond_to_should_look_for_variables
53
+ assert !@config.respond_to?(:sample)
54
+ @config[:sample] = :value
55
+ assert @config.respond_to?(:sample)
56
+ end
57
+
58
+ def test_respond_to_should_be_true_when_passed_a_string
59
+ assert !@config.respond_to?('sample')
60
+ @config[:sample] = :value
61
+ assert @config.respond_to?('sample')
62
+ end
63
+
64
+ def test_respond_to_with_include_priv_paramter
65
+ assert !@config.respond_to?(:sample, true)
66
+ end
67
+
68
+ def test_set_should_require_value
69
+ assert_raises(ArgumentError) do
70
+ @config.set(:sample)
71
+ end
72
+ end
73
+
74
+ def test_set_should_allow_value_to_be_omitted_if_block_is_given
75
+ assert_nothing_raised do
76
+ @config.set(:sample) { :value }
77
+ end
78
+ assert_instance_of Proc, @config.variables[:sample]
79
+ end
80
+
81
+ def test_set_should_not_allow_multiple_values
82
+ assert_raises(ArgumentError) do
83
+ @config.set(:sample, :value, :another)
84
+ end
85
+ end
86
+
87
+ def test_set_should_not_allow_both_a_value_and_a_block
88
+ assert_raises(ArgumentError) do
89
+ @config.set(:sample, :value) { :block }
90
+ end
91
+ end
92
+
93
+ def test_set_should_not_allow_capitalized_variables
94
+ assert_raises(ArgumentError) do
95
+ @config.set :Sample, :value
96
+ end
97
+ end
98
+
99
+ def test_unset_should_remove_variable_from_hash
100
+ @config.set :sample, :value
101
+ assert @config.variables.key?(:sample)
102
+ @config.unset :sample
103
+ assert !@config.variables.key?(:sample)
104
+ end
105
+
106
+ def test_unset_should_clear_memory_of_original_proc
107
+ @config.set(:sample) { :value }
108
+ @config.fetch(:sample)
109
+ @config.unset(:sample)
110
+ assert_equal false, @config.reset!(:sample)
111
+ end
112
+
113
+ def test_exists_should_report_existance_of_variable_in_hash
114
+ assert !@config.exists?(:sample)
115
+ @config[:sample] = :value
116
+ assert @config.exists?(:sample)
117
+ end
118
+
119
+ def test_reset_should_do_nothing_if_variable_does_not_exist
120
+ assert_equal false, @config.reset!(:sample)
121
+ assert !@config.variables.key?(:sample)
122
+ end
123
+
124
+ def test_reset_should_do_nothing_if_variable_is_not_a_proc
125
+ @config.set(:sample, :value)
126
+ assert_equal false, @config.reset!(:sample)
127
+ assert_equal :value, @config.variables[:sample]
128
+ end
129
+
130
+ def test_reset_should_do_nothing_if_proc_variable_has_not_been_dereferenced
131
+ @config.set(:sample) { :value }
132
+ assert_equal false, @config.reset!(:sample)
133
+ assert_instance_of Proc, @config.variables[:sample]
134
+ end
135
+
136
+ def test_reset_should_restore_variable_to_original_proc_value
137
+ @config.set(:sample) { :value }
138
+ assert_instance_of Proc, @config.variables[:sample]
139
+ @config.fetch(:sample)
140
+ assert_instance_of Symbol, @config.variables[:sample]
141
+ assert @config.reset!(:sample)
142
+ assert_instance_of Proc, @config.variables[:sample]
143
+ end
144
+
145
+ def test_fetch_should_return_stored_non_proc_value
146
+ @config.set(:sample, :value)
147
+ assert_equal :value, @config.fetch(:sample)
148
+ end
149
+
150
+ def test_fetch_should_raise_index_error_if_variable_does_not_exist
151
+ assert_raises(IndexError) do
152
+ @config.fetch(:sample)
153
+ end
154
+ end
155
+
156
+ def test_fetch_should_return_default_if_variable_does_not_exist_and_default_is_given
157
+ assert_nothing_raised do
158
+ assert_equal :default_value, @config.fetch(:sample, :default_value)
159
+ end
160
+ end
161
+
162
+ def test_fetch_should_invoke_block_if_variable_does_not_exist_and_block_is_given
163
+ assert_nothing_raised do
164
+ assert_equal :default_value, @config.fetch(:sample) { :default_value }
165
+ end
166
+ end
167
+
168
+ def test_fetch_should_raise_argument_error_if_both_default_and_block_are_given
169
+ assert_raises(ArgumentError) do
170
+ @config.fetch(:sample, :default1) { :default2 }
171
+ end
172
+ end
173
+
174
+ def test_fetch_should_dereference_proc_values
175
+ @config.set(:sample) { :value }
176
+ assert_instance_of Proc, @config.variables[:sample]
177
+ assert_equal :value, @config.fetch(:sample)
178
+ assert_instance_of Symbol, @config.variables[:sample]
179
+ end
180
+
181
+ def test_square_brackets_should_alias_fetch
182
+ @config.set(:sample, :value)
183
+ assert_equal :value, @config[:sample]
184
+ end
185
+
186
+ def test_square_brackets_should_return_nil_for_non_existant_variable
187
+ assert_nothing_raised do
188
+ assert_nil @config[:sample]
189
+ end
190
+ end
191
+ end
@@ -0,0 +1,77 @@
1
+ require "utils"
2
+ require 'minestrone/configuration'
3
+
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.
7
+
8
+ class ConfigurationTest < Test::Unit::TestCase
9
+ def setup
10
+ @config = Minestrone::Configuration.new
11
+ end
12
+
13
+ def test_connections_execution_loading_namespaces_servers_and_variables_modules_should_integrate_correctly
14
+ Minestrone::SSH.expects(:connect).with { |s,c| s.host == "www.minestrone.test" && c == @config }.returns(:session)
15
+
16
+ process_args = Proc.new do |command, session, opts|
17
+ command == "echo 'hello world'" &&
18
+ session == :session &&
19
+ opts == { :logger => @config.logger, :eof => true, :configuration => @config }
20
+ end
21
+
22
+ Minestrone::Command.expects(:process).with(&process_args)
23
+
24
+ @config.load do
25
+ server "www.minestrone.test"
26
+ set :message, "hello world"
27
+ namespace :testing do
28
+ task :example do
29
+ run "echo '#{message}'"
30
+ end
31
+ end
32
+ end
33
+
34
+ @config.testing.example
35
+ end
36
+
37
+ def test_tasks_in_nested_namespace_should_be_able_to_call_tasks_in_same_namespace
38
+ @config.namespace(:outer) do
39
+ task(:first) { set :called_first, true }
40
+ namespace(:inner) do
41
+ task(:first) { set :called_inner_first, true }
42
+ task(:second) { first }
43
+ end
44
+ end
45
+
46
+ @config.outer.inner.second
47
+ assert !@config[:called_first]
48
+ assert @config[:called_inner_first]
49
+ end
50
+
51
+ def test_tasks_in_nested_namespace_should_be_able_to_call_tasks_in_parent_namespace
52
+ @config.namespace(:outer) do
53
+ task(:first) { set :called_first, true }
54
+ namespace(:inner) do
55
+ task(:second) { first }
56
+ end
57
+ end
58
+
59
+ @config.outer.inner.second
60
+ assert @config[:called_first]
61
+ end
62
+
63
+ def test_tasks_in_nested_namespace_should_be_able_to_call_shadowed_tasks_in_parent_namespace
64
+ @config.namespace(:outer) do
65
+ task(:first) { set :called_first, true }
66
+ namespace(:inner) do
67
+ task(:first) { set :called_inner_first, true }
68
+ task(:second) { parent.first }
69
+ end
70
+ end
71
+
72
+ @config.outer.inner.second
73
+ assert @config[:called_first]
74
+ assert !@config[:called_inner_first]
75
+ end
76
+
77
+ end
@@ -0,0 +1,61 @@
1
+ require "utils"
2
+ require 'minestrone/recipes/deploy/local_dependency'
3
+
4
+ class LocalDependencyTest < Test::Unit::TestCase
5
+ def setup
6
+ @config = { }
7
+ @dependency = Minestrone::Deploy::LocalDependency.new(@config)
8
+ end
9
+
10
+ def test_should_use_standard_error_message
11
+ setup_for_one_path_entry(false)
12
+ @dependency.command("cat")
13
+ assert_equal "`cat' could not be found in the path on the local host", @dependency.message
14
+ end
15
+
16
+ def test_should_use_alternative_message_if_provided
17
+ setup_for_one_path_entry(false)
18
+ @dependency.command("cat").or("Sorry")
19
+ assert_equal "Sorry", @dependency.message
20
+ end
21
+
22
+ def test_env_with_no_path_should_never_find_command
23
+ ENV.expects(:[]).with("PATH").returns(nil)
24
+ assert !@dependency.command("cat").pass?
25
+ end
26
+
27
+ def test_env_with_one_path_entry_should_fail_if_command_not_found
28
+ setup_for_one_path_entry(false)
29
+ assert !@dependency.command("cat").pass?
30
+ end
31
+
32
+ def test_env_with_one_path_entry_should_pass_if_command_found
33
+ setup_for_one_path_entry(true)
34
+ assert @dependency.command("cat").pass?
35
+ end
36
+
37
+ def test_env_with_three_path_entries_should_fail_if_command_not_found
38
+ setup_for_three_path_entries(false)
39
+ assert !@dependency.command("cat").pass?
40
+ end
41
+
42
+ def test_env_with_three_path_entries_should_pass_if_command_found
43
+ setup_for_three_path_entries(true)
44
+ assert @dependency.command("cat").pass?
45
+ end
46
+
47
+ private
48
+
49
+ def setup_for_one_path_entry(command_found)
50
+ ENV.expects(:[]).with("PATH").returns("/bin")
51
+ File.expects(:executable?).with("/bin/cat").returns(command_found)
52
+ end
53
+
54
+ def setup_for_three_path_entries(command_found)
55
+ path = %w(/bin /usr/bin /usr/local/bin).join(File::PATH_SEPARATOR)
56
+ ENV.expects(:[]).with("PATH").returns(path)
57
+ File.expects(:executable?).with("/usr/bin/cat").returns(command_found)
58
+ File.expects(:executable?).at_most(1).with("/bin/cat").returns(false)
59
+ File.expects(:executable?).at_most(1).with("/usr/local/bin/cat").returns(false)
60
+ end
61
+ end
@@ -0,0 +1,146 @@
1
+ require "utils"
2
+ require 'minestrone/recipes/deploy/remote_dependency'
3
+
4
+ class RemoteDependencyTest < Test::Unit::TestCase
5
+ def setup
6
+ @config = { }
7
+ @dependency = Minestrone::Deploy::RemoteDependency.new(@config)
8
+ end
9
+
10
+ def test_should_use_standard_error_message_for_directory
11
+ setup_for_a_configuration_run("test -d /data", false)
12
+ @dependency.directory("/data")
13
+ assert_equal "`/data' is not a directory (host)", @dependency.message
14
+ end
15
+
16
+ def test_should_use_standard_error_message_for_file
17
+ setup_for_a_configuration_run("test -f /data/foo.txt", false)
18
+ @dependency.file("/data/foo.txt")
19
+ assert_equal "`/data/foo.txt' is not a file (host)", @dependency.message
20
+ end
21
+
22
+ def test_should_use_standard_error_message_for_writable
23
+ setup_for_a_configuration_run("test -w /data/foo.txt", false)
24
+ @dependency.writable("/data/foo.txt")
25
+ assert_equal "`/data/foo.txt' is not writable (host)", @dependency.message
26
+ end
27
+
28
+ def test_should_use_standard_error_message_for_command
29
+ setup_for_a_configuration_run("which cat", false)
30
+ @dependency.command("cat")
31
+ assert_equal "`cat' could not be found in the path (host)", @dependency.message
32
+ end
33
+
34
+ def test_should_use_standard_error_message_for_gem
35
+ setup_for_a_configuration_gem_run("minestrone", "9.9", false)
36
+ @dependency.gem("minestrone", 9.9)
37
+ assert_equal "gem `minestrone' 9.9 could not be found (host)", @dependency.message
38
+ end
39
+
40
+ def test_should_use_standard_error_message_for_deb
41
+ setup_for_a_configuration_deb_run("dpkg", "1.15", false)
42
+ @dependency.deb("dpkg", "1.15")
43
+ assert_equal "package `dpkg' 1.15 could not be found (host)", @dependency.message
44
+ end
45
+
46
+ def test_should_use_standard_error_message_for_rpm
47
+ setup_for_a_configuration_rpm_run("rpm", "4.8", false)
48
+ @dependency.rpm("rpm", "4.8")
49
+ assert_equal "package `rpm' 4.8 could not be found (host)", @dependency.message
50
+ end
51
+
52
+ def test_should_fail_if_directory_not_found
53
+ setup_for_a_configuration_run("test -d /data", false)
54
+ assert !@dependency.directory("/data").pass?
55
+ end
56
+
57
+ def test_should_pass_if_directory_found
58
+ setup_for_a_configuration_run("test -d /data", true)
59
+ assert @dependency.directory("/data").pass?
60
+ end
61
+
62
+ def test_should_fail_if_file_not_found
63
+ setup_for_a_configuration_run("test -f /data/foo.txt", false)
64
+ assert !@dependency.file("/data/foo.txt").pass?
65
+ end
66
+
67
+ def test_should_pass_if_file_found
68
+ setup_for_a_configuration_run("test -f /data/foo.txt", true)
69
+ assert @dependency.file("/data/foo.txt").pass?
70
+ end
71
+
72
+ def test_should_fail_if_writable_not_found
73
+ setup_for_a_configuration_run("test -w /data/foo.txt", false)
74
+ assert !@dependency.writable("/data/foo.txt").pass?
75
+ end
76
+
77
+ def test_should_pass_if_writable_found
78
+ setup_for_a_configuration_run("test -w /data/foo.txt", true)
79
+ assert @dependency.writable("/data/foo.txt").pass?
80
+ end
81
+
82
+ def test_should_fail_if_command_not_found
83
+ setup_for_a_configuration_run("which cat", false)
84
+ assert !@dependency.command("cat").pass?
85
+ end
86
+
87
+ def test_should_pass_if_command_found
88
+ setup_for_a_configuration_run("which cat", true)
89
+ assert @dependency.command("cat").pass?
90
+ end
91
+
92
+ def test_should_fail_if_gem_not_found
93
+ setup_for_a_configuration_gem_run("minestrone", "9.9", false)
94
+ assert !@dependency.gem("minestrone", 9.9).pass?
95
+ end
96
+
97
+ def test_should_pass_if_gem_found
98
+ setup_for_a_configuration_gem_run("minestrone", "9.9", true)
99
+ assert @dependency.gem("minestrone", 9.9).pass?
100
+ end
101
+
102
+ def test_should_pass_if_deb_found
103
+ setup_for_a_configuration_deb_run("dpkg", "1.15", true)
104
+ assert @dependency.deb("dpkg", "1.15").pass?
105
+ end
106
+
107
+ def test_should_fail_if_deb_not_found
108
+ setup_for_a_configuration_deb_run("dpkg", "1.15", false)
109
+ assert !@dependency.deb("dpkg", "1.15").pass?
110
+ end
111
+
112
+ def test_should_use_alternative_message_if_provided
113
+ setup_for_a_configuration_run("which cat", false)
114
+ @dependency.command("cat").or("Sorry")
115
+ assert_equal "Sorry (host)", @dependency.message
116
+ end
117
+
118
+ private
119
+
120
+ def setup_for_a_configuration_run(command, passing)
121
+ expectation = @config.expects(:invoke_command).with(command, {})
122
+ if passing
123
+ expectation.returns(true)
124
+ else
125
+ error = Minestrone::CommandError.new
126
+ error.expects(:host).returns("host")
127
+ expectation.raises(error)
128
+ end
129
+ end
130
+
131
+ def setup_for_a_configuration_gem_run(name, version, passing)
132
+ @config.expects(:fetch).with(:gem_command, "gem").returns("gem")
133
+ find_gem_cmd = "gem specification --version '#{version}' #{name} 2>&1 | awk 'BEGIN { s = 0 } /^name:/ { s = 1; exit }; END { if(s == 0) exit 1 }'"
134
+ setup_for_a_configuration_run(find_gem_cmd, passing)
135
+ end
136
+
137
+ def setup_for_a_configuration_deb_run(name, version, passing)
138
+ find_deb_cmd = "dpkg -s #{name} | grep '^Version: #{version}'"
139
+ setup_for_a_configuration_run(find_deb_cmd, passing)
140
+ end
141
+
142
+ def setup_for_a_configuration_rpm_run(name, version, passing)
143
+ find_rpm_cmd = "rpm -q #{name} | grep '#{version}'"
144
+ setup_for_a_configuration_run(find_rpm_cmd, passing)
145
+ end
146
+ end
@@ -0,0 +1,55 @@
1
+ require "utils"
2
+ require 'minestrone/recipes/deploy/scm/base'
3
+
4
+ class DeploySCMBaseTest < Test::Unit::TestCase
5
+ class TestSCM < Minestrone::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