Commit 1defb950 authored by Dylan Griffith's avatar Dylan Griffith

Update Factory::Repository::Push to allow pushing directory to simplfy auto devops spec

parent 282c09ed
...@@ -15,15 +15,23 @@ module QA ...@@ -15,15 +15,23 @@ module QA
def initialize def initialize
@file_name = 'file.txt' @file_name = 'file.txt'
@file_content = '# This is test project' @file_content = '# This is test project'
@commit_message = "Add #{@file_name}" @commit_message = "This is a test commit"
@branch_name = 'master' @branch_name = 'master'
@new_branch = true @new_branch = true
@pushing_directory = false
end end
def remote_branch def remote_branch
@remote_branch ||= branch_name @remote_branch ||= branch_name
end end
def directory=(dir)
raise "Must set directory as a Pathname" unless dir.is_a?(Pathname)
@directory = dir
@pushing_directory = true
end
def fabricate! def fabricate!
project.visit! project.visit!
...@@ -43,7 +51,14 @@ module QA ...@@ -43,7 +51,14 @@ module QA
repository.checkout(branch_name) repository.checkout(branch_name)
end end
repository.add_file(file_name, file_content) if @pushing_directory
@directory.each_child do |f|
repository.add_file(f.basename, f.read) if f.file?
end
else
repository.add_file(file_name, file_content)
end
repository.commit(commit_message) repository.commit(commit_message)
repository.push_changes("#{branch_name}:#{remote_branch}") repository.push_changes("#{branch_name}:#{remote_branch}")
end end
......
...@@ -16,26 +16,16 @@ module QA ...@@ -16,26 +16,16 @@ module QA
end end
# Create Auto Devops compatible repo # Create Auto Devops compatible repo
project.visit! Factory::Repository::Push.fabricate! do |push|
Git::Repository.perform do |repository| push.project = project
repository.uri = Page::Project::Show.act do push.directory = Pathname
choose_repository_clone_http .new(__dir__)
repository_location.uri .join('../../../fixtures/auto_devops_rack')
end push.commit_message = 'Create Auto DevOps compatible rack application'
repository.use_default_credentials
repository.clone
repository.configure_identity('GitLab QA', 'root@gitlab.com')
repository.checkout_new_branch('master')
repository.add_file('config.ru', File.read(File.join(__dir__, "../../../fixtures/auto_devops_rack/config.ru")))
repository.add_file('Gemfile', File.read(File.join(__dir__, "../../../fixtures/auto_devops_rack/Gemfile")))
repository.add_file('Gemfile.lock', File.read(File.join(__dir__, "../../../fixtures/auto_devops_rack/Gemfile.lock")))
repository.add_file('Rakefile', File.read(File.join(__dir__, "../../../fixtures/auto_devops_rack/Rakefile")))
repository.commit('Create auto devops repo')
repository.push_changes("master:master")
end end
Page::Project::Show.act { wait_for_push }
# Create and connect K8s cluster # Create and connect K8s cluster
@cluster = Service::KubernetesCluster.new.create! @cluster = Service::KubernetesCluster.new.create!
kubernetes_cluster = Factory::Resource::KubernetesCluster.fabricate! do |c| kubernetes_cluster = Factory::Resource::KubernetesCluster.fabricate! do |c|
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment