Commit ebacad4e authored by Mark Lapierre's avatar Mark Lapierre Committed by Dan Davison

Update tests that use a blank repo with no branch

Tests that push to an empty repo need to specify the branch, otherwise
they'll fail if the local default (e.g., master) is different from
GitLab's default (e.g., main).
parent ad576c0c
...@@ -25,10 +25,6 @@ module QA ...@@ -25,10 +25,6 @@ module QA
attribute :template_name attribute :template_name
attribute :import attribute :import
attribute :default_branch do
api_response[:default_branch] || Runtime::Env.default_branch
end
attribute :group do attribute :group do
Group.fabricate! Group.fabricate!
end end
...@@ -224,6 +220,10 @@ module QA ...@@ -224,6 +220,10 @@ module QA
parse_body(get(Runtime::API::Request.new(api_client, api_commits_path).url)) parse_body(get(Runtime::API::Request.new(api_client, api_commits_path).url))
end end
def default_branch
reload!.api_response[:default_branch] || Runtime::Env.default_branch
end
def import_status def import_status
response = get Runtime::API::Request.new(api_client, "/projects/#{id}/import").url response = get Runtime::API::Request.new(api_client, "/projects/#{id}/import").url
......
...@@ -12,14 +12,11 @@ module QA ...@@ -12,14 +12,11 @@ module QA
end end
end end
def branch_name
@branch_name ||= wiki.project.default_branch
end
def initialize def initialize
@file_name = 'Home.md' @file_name = 'Home.md'
@file_content = 'This line was created using git push' @file_content = 'This line was created using git push'
@commit_message = 'Updating using git push' @commit_message = 'Updating using git push'
@branch_name = 'master'
@new_branch = false @new_branch = false
end end
......
...@@ -14,10 +14,12 @@ module QA ...@@ -14,10 +14,12 @@ module QA
Git::Repository.perform do |repository| Git::Repository.perform do |repository|
repository.uri = project.repository_http_location.uri repository.uri = project.repository_http_location.uri
repository.use_default_credentials repository.use_default_credentials
repository.default_branch = project.default_branch
repository.act do repository.act do
clone clone
configure_identity('GitLab QA', 'root@gitlab.com') configure_identity('GitLab QA', 'root@gitlab.com')
checkout(default_branch, new_branch: true)
commit_file('test.rb', 'class Test; end', 'Add Test class') commit_file('test.rb', 'class Test; end', 'Add Test class')
commit_file('README.md', '# Test', 'Add Readme') commit_file('README.md', '# Test', 'Add Readme')
push_changes push_changes
......
...@@ -26,6 +26,8 @@ module QA ...@@ -26,6 +26,8 @@ module QA
repository.use_default_credentials repository.use_default_credentials
repository.clone repository.clone
repository.configure_identity(username, email) repository.configure_identity(username, email)
repository.default_branch = project.default_branch
repository.checkout(project.default_branch, new_branch: true)
git_protocol_reported = repository.push_with_git_protocol( git_protocol_reported = repository.push_with_git_protocol(
git_protocol, git_protocol,
......
...@@ -49,6 +49,8 @@ module QA ...@@ -49,6 +49,8 @@ module QA
repository.use_ssh_key(ssh_key) repository.use_ssh_key(ssh_key)
repository.clone repository.clone
repository.configure_identity(username, email) repository.configure_identity(username, email)
repository.default_branch = project.default_branch
repository.checkout(project.default_branch, new_branch: true)
git_protocol_reported = repository.push_with_git_protocol( git_protocol_reported = repository.push_with_git_protocol(
git_protocol, git_protocol,
......
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