Skip to content

Commit bcc99c9

Browse files
committed
Add tests for freeze_release_branch
1 parent 93918a8 commit bcc99c9

2 files changed

Lines changed: 55 additions & 3 deletions

File tree

lib/fastlane/plugin/ddg_apple_automation/helper/git_helper.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,12 +178,16 @@ def self.freeze_release_branch(platform, github_token, other_action)
178178

179179
UI.message("Creating draft public release #{draft_public_release_name}")
180180

181+
description = <<~DESCRIPTION
182+
This draft release is here to indicate that the release branch is frozen.
183+
New internal releases on `release/#{platform}/#{latest_marketing_version}` branch cannot be created.
184+
If you need to bump the internal release, please manually delete this draft release.
185+
DESCRIPTION
186+
181187
other_action.set_github_release(
182188
repository_name: repo_name,
183189
api_bearer: github_token,
184-
description: "This draft release is here to indicate that the release branch is frozen.
185-
New internal releases on `release/#{platform}/#{latest_marketing_version}` branch cannot be created.
186-
If you need to bump the internal release, please manually delete this draft release.",
190+
description: description,
187191
name: draft_public_release_name,
188192
tag_name: "",
189193
is_draft: true,

spec/git_helper_spec.rb

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
shared_context "common setup" do
99
before do
1010
allow(Octokit::Client).to receive(:new).and_return(client)
11+
allow(Fastlane::UI).to receive(:message)
1112
allow(Fastlane::UI).to receive(:success)
1213
allow(Fastlane::UI).to receive(:important)
1314
end
@@ -334,6 +335,53 @@ def validate_semver(version)
334335
end
335336
end
336337

338+
describe "#freeze_release_branch" do
339+
subject { Fastlane::Helper::GitHelper.freeze_release_branch(platform, github_token, other_action) }
340+
let(:other_action) { double(set_github_release: nil) }
341+
let(:platform) { "ios" }
342+
let(:latest_release_name) { "1.0.0+ios" }
343+
let(:latest_marketing_version) { "1.0.1" }
344+
345+
include_context "common setup"
346+
347+
before do
348+
allow(Fastlane::Helper::GitHelper).to receive(:find_latest_marketing_version).and_return(latest_marketing_version)
349+
allow(Fastlane::Helper::GitHelper).to receive(:latest_release).and_return(double(name: latest_release_name))
350+
allow(other_action).to receive(:set_github_release)
351+
end
352+
353+
context "when the release branch is already frozen" do
354+
let(:latest_release_name) { "1.0.1+ios" }
355+
356+
it "does not create a draft public release" do
357+
subject
358+
expect(other_action).not_to have_received(:set_github_release)
359+
end
360+
end
361+
362+
context "when the release branch is not frozen" do
363+
it "creates a draft public release" do
364+
subject
365+
366+
description = <<~DESCRIPTION
367+
This draft release is here to indicate that the release branch is frozen.
368+
New internal releases on `release/ios/1.0.1` branch cannot be created.
369+
If you need to bump the internal release, please manually delete this draft release.
370+
DESCRIPTION
371+
372+
expect(other_action).to have_received(:set_github_release).with(
373+
api_bearer: github_token,
374+
description: description,
375+
is_draft: true,
376+
is_prerelease: false,
377+
name: "1.0.1+ios",
378+
repository_name: Fastlane::Helper::GitHelper.repo_name,
379+
tag_name: ""
380+
)
381+
end
382+
end
383+
end
384+
337385
describe "#assert_branch_has_changes" do
338386
subject { Fastlane::Helper::GitHelper.assert_branch_has_changes("release_branch", platform) }
339387

0 commit comments

Comments
 (0)