class MockCodeManager::MockCodeManager
Public Instance Methods
get_all_branches()
click to toggle source
# File lib/mock_code_manager.rb, line 43 def get_all_branches branches = {} output = %x(git ls-remote #{TEST_REPO}) output.split("\n").each do |line| line_split = line.split(/\t/) if line_split.length == 2 environment = line_split[1].split(/\//)[-1] revision = line_split[0] branches[environment] = revision else puts "skipped invalid input: #{line}" end end return branches end
get_deploy_all_json(wait)
click to toggle source
# File lib/mock_code_manager.rb, line 60 def get_deploy_all_json(wait) get_deploy_json(get_all_branches.keys.sort, wait) end
get_deploy_json(requested_branches, wait)
click to toggle source
# File lib/mock_code_manager.rb, line 64 def get_deploy_json(requested_branches, wait) json = [] branches = get_all_branches id = IDOK requested_branches.each { |requested_branch| if branches.has_key? requested_branch if wait # in wait mode, sleep for a while to simulate a slow-ish server sleep(1 + rand(10)) json << { "environment"=>requested_branch, "id"=>id, "status"=>STATUS_COMPLETE, "file-sync"=> { "environment-commit"=>JUNK_ID, "code-commit"=>JUNK_ID }, "deploy-signature"=>branches[requested_branch] } else json << { "environment"=>requested_branch, "id"=>id, "status"=>STATUS_QUEUED } end else json << { "environment"=>requested_branch, "id"=>id, "status"=>STATUS_FAILED, "error"=>{ "kind"=>"puppetlabs.code-manager/deploy-failure", "details"=>{ "corrected-env-name"=>requested_branch}, "msg"=>"Errors while deploying environment '#{requested_branch}' (exit code: 1):\nERROR\t -> Environment(s) '#{requested_branch}' cannot be found in any source and will not be deployed.\n" } } end id += 1 } json end