Skip to content

Commit

Permalink
fixing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kshann committed Nov 21, 2024
1 parent 7f21c65 commit 1f7219b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,11 @@ def self.current_version
def self.prepare_release_branch(platform, version, other_action)
code_freeze_prechecks(other_action) unless Helper.is_ci?
new_version = validate_new_version(version)
release_branch_name = create_release_branch(new_version)
create_release_branch(new_version)
update_embedded_files(platform, other_action)
update_version_config(new_version, other_action)
other_action.push_to_git_remote
release_branch_name = "#{RELEASE_BRANCH}/#{new_version}"
Helper::GitHubActionsHelper.set_output("release_branch_name", release_branch_name)

return release_branch_name, new_version
Expand Down Expand Up @@ -200,8 +201,6 @@ def self.create_release_branch(version)
# Create the branch and push
Actions.sh('git', 'checkout', '-b', release_branch)
Actions.sh('git', 'push', '-u', 'origin', release_branch)

release_branch
end

def self.update_embedded_files(platform, other_action)
Expand Down
6 changes: 4 additions & 2 deletions spec/ddg_apple_automation_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def load_file(file)
it "prepares the release branch with version updates" do
allow(Fastlane::Helper::DdgAppleAutomationHelper).to receive(:code_freeze_prechecks)
allow(Fastlane::Helper::DdgAppleAutomationHelper).to receive(:validate_new_version).and_return(version)
allow(Fastlane::Helper::DdgAppleAutomationHelper).to receive(:create_release_branch).and_return("release/1.0.0")
allow(Fastlane::Helper::DdgAppleAutomationHelper).to receive(:create_release_branch)
allow(Fastlane::Helper::DdgAppleAutomationHelper).to receive(:update_embedded_files)
allow(Fastlane::Helper::DdgAppleAutomationHelper).to receive(:update_version_config)
expect(other_action).to receive(:push_to_git_remote)
Expand All @@ -148,6 +148,8 @@ def load_file(file)

it "raises an error when the branch already exists" do
allow(Fastlane::Actions).to receive(:sh).with("git", "branch", "--list", "hotfix/1.0.1").and_return("hotfix/1.0.1")
source_version = "1.0.0"
new_version = "1.0.1"
expect do
Fastlane::Helper::DdgAppleAutomationHelper.create_hotfix_branch(source_version, new_version)
end.to raise_error(FastlaneCore::Interface::FastlaneCommonException, "Branch hotfix/1.0.1 already exists in this repository. Aborting.")
Expand All @@ -173,7 +175,7 @@ def load_file(file)
formatted_version = "1.0.0"
allow(Fastlane::Helper::DdgAppleAutomationHelper).to receive(:format_version).with(version).and_return(formatted_version)
allow(Fastlane::Actions).to receive(:sh).with("git", "fetch", "--tags")
allow(Fastlane::Helper::DdgAppleAutomationHelper).to receive(:sh).with("git", "tag", "--list", formatted_version).and_return(formatted_version)
allow(Fastlane::Actions).to receive(:sh).with("git", "tag", "--list", formatted_version).and_return(formatted_version)

result = Fastlane::Helper::DdgAppleAutomationHelper.validate_version_exists(version)
expect(result).to eq(formatted_version)
Expand Down

0 comments on commit 1f7219b

Please sign in to comment.