2013-09-27 06:45:55 -04:00
|
|
|
Given(/^a test app with the default configuration$/) do
|
|
|
|
TestApp.install
|
|
|
|
end
|
|
|
|
|
2017-03-19 22:58:09 -04:00
|
|
|
Given(/^a test app without any configuration$/) do
|
|
|
|
TestApp.create_test_app
|
|
|
|
end
|
|
|
|
|
2013-09-27 06:45:55 -04:00
|
|
|
Given(/^servers with the roles app and web$/) do
|
2016-03-01 10:34:31 -05:00
|
|
|
begin
|
|
|
|
vagrant_cli_command("up")
|
|
|
|
rescue
|
|
|
|
nil
|
|
|
|
end
|
2013-09-27 06:45:55 -04:00
|
|
|
end
|
|
|
|
|
2014-04-26 07:27:24 -04:00
|
|
|
Given(/^a linked file "(.*?)"$/) do |file|
|
|
|
|
# ignoring other linked files
|
|
|
|
TestApp.append_to_deploy_file("set :linked_files, ['#{file}']")
|
2013-09-27 06:45:55 -04:00
|
|
|
end
|
|
|
|
|
2014-04-26 07:27:24 -04:00
|
|
|
Given(/^file "(.*?)" exists in shared path$/) do |file|
|
|
|
|
file_shared_path = TestApp.shared_path.join(file)
|
2017-07-04 22:02:58 -04:00
|
|
|
run_vagrant_command("mkdir -p #{file_shared_path.dirname}")
|
2014-04-26 07:27:24 -04:00
|
|
|
run_vagrant_command("touch #{file_shared_path}")
|
2013-09-27 06:45:55 -04:00
|
|
|
end
|
|
|
|
|
2017-07-04 22:02:58 -04:00
|
|
|
Given(/^all linked files exists in shared path$/) do
|
|
|
|
TestApp.linked_files.each do |linked_file|
|
|
|
|
step %Q{file "#{linked_file}" exists in shared path}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-04-26 07:27:24 -04:00
|
|
|
Given(/^file "(.*?)" does not exist in shared path$/) do |file|
|
|
|
|
file_shared_path = TestApp.shared_path.join(file)
|
|
|
|
run_vagrant_command("mkdir -p #{TestApp.shared_path}")
|
|
|
|
run_vagrant_command("touch #{file_shared_path} && rm #{file_shared_path}")
|
2013-09-27 06:45:55 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
Given(/^a custom task to generate a file$/) do
|
2016-02-28 18:16:11 -05:00
|
|
|
TestApp.copy_task_to_test_app("spec/support/tasks/database.rake")
|
2013-09-27 06:45:55 -04:00
|
|
|
end
|
|
|
|
|
2015-02-12 20:34:09 -05:00
|
|
|
Given(/^a task which executes as root$/) do
|
2016-02-28 18:16:11 -05:00
|
|
|
TestApp.copy_task_to_test_app("spec/support/tasks/root.rake")
|
2015-02-12 20:34:09 -05:00
|
|
|
end
|
|
|
|
|
2014-01-18 16:18:55 -05:00
|
|
|
Given(/config stage file has line "(.*?)"/) do |line|
|
|
|
|
TestApp.append_to_deploy_file(line)
|
|
|
|
end
|
|
|
|
|
2013-10-11 12:24:37 -04:00
|
|
|
Given(/^the configuration is in a custom location$/) do
|
2016-02-28 18:16:11 -05:00
|
|
|
TestApp.move_configuration_to_custom_location("app")
|
2013-10-11 12:24:37 -04:00
|
|
|
end
|
2013-11-01 07:59:13 -04:00
|
|
|
|
|
|
|
Given(/^a custom task that will simulate a failure$/) do
|
2016-02-28 18:16:11 -05:00
|
|
|
safely_remove_file(TestApp.shared_path.join("failed"))
|
|
|
|
TestApp.copy_task_to_test_app("spec/support/tasks/fail.rake")
|
2013-11-01 07:59:13 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
Given(/^a custom task to run in the event of a failure$/) do
|
2016-02-28 18:16:11 -05:00
|
|
|
safely_remove_file(TestApp.shared_path.join("failed"))
|
|
|
|
TestApp.copy_task_to_test_app("spec/support/tasks/failed.rake")
|
2013-11-01 07:59:13 -04:00
|
|
|
end
|
2016-05-21 14:55:57 -04:00
|
|
|
|
|
|
|
Given(/^a stage file named (.+)$/) do |filename|
|
|
|
|
TestApp.write_local_stage_file(filename)
|
|
|
|
end
|
2017-07-04 22:02:58 -04:00
|
|
|
|
|
|
|
Given(/^I make (\d+) deployments$/) do |count|
|
|
|
|
step "all linked files exists in shared path"
|
|
|
|
|
|
|
|
@release_paths = (1..count.to_i).map do
|
|
|
|
TestApp.cap("deploy")
|
|
|
|
stdout, _stderr = run_vagrant_command("readlink #{TestApp.current_path}")
|
|
|
|
|
|
|
|
stdout.strip
|
|
|
|
end
|
|
|
|
end
|
2017-07-22 19:15:44 -04:00
|
|
|
|
|
|
|
Given(/^(\d+) valid existing releases$/) do |num|
|
|
|
|
a_day = 86_400 # in seconds
|
2019-08-28 21:17:26 -04:00
|
|
|
(1...num).each_slice(100) do |num_batch|
|
|
|
|
dirs = num_batch.map do |i|
|
|
|
|
offset = -(a_day * i)
|
|
|
|
TestApp.release_path(TestApp.timestamp(offset))
|
|
|
|
end
|
|
|
|
run_vagrant_command("mkdir -p #{dirs.join(' ')}")
|
2017-07-22 19:15:44 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
Given(/^an invalid release named "(.+)"$/) do |filename|
|
|
|
|
run_vagrant_command("mkdir -p #{TestApp.release_path(filename)}")
|
|
|
|
end
|