|
21 | 21 | allow(Fastlane::Actions).to receive(:other_action).and_return(@other_action) |
22 | 22 | allow(Fastlane::Actions::AsanaFindReleaseTaskAction).to receive(:find_latest_marketing_version) |
23 | 23 | .and_return("1.0.0") |
24 | | - |
25 | | - allow(Fastlane::Actions::ValidateInternalReleaseBumpAction).to receive(:find_release_task_if_needed) do |params| |
26 | | - params[:release_branch] = "release_branch_name" |
27 | | - params[:release_task_id] = "mock_task_id" |
28 | | - end |
29 | 24 | end |
30 | 25 | end |
31 | 26 |
|
|
48 | 43 | end |
49 | 44 | include_context "common setup" |
50 | 45 |
|
| 46 | + before do |
| 47 | + allow(Fastlane::Actions::ValidateInternalReleaseBumpAction).to receive(:find_release_task_if_needed) do |params| |
| 48 | + params[:release_branch] = "release_branch_name" |
| 49 | + params[:release_task_id] = "mock_task_id" |
| 50 | + end |
| 51 | + end |
| 52 | + |
51 | 53 | context "when there are changes in the release branch" do |
52 | 54 | it "proceeds with release bump if release notes are valid" do |
53 | 55 | expect(Fastlane::UI).to receive(:message).with("Validating release notes") |
|
94 | 96 | describe "#find_release_task_if_needed" do |
95 | 97 | include_context "common setup" |
96 | 98 |
|
| 99 | + subject { Fastlane::Actions::ValidateInternalReleaseBumpAction.find_release_task_if_needed(@params) } |
| 100 | + |
97 | 101 | context "when release_task_url is provided" do |
| 102 | + before do |
| 103 | + @params[:release_task_url] = "https://app.asana.com/0/1234567890/987654321" |
| 104 | + end |
| 105 | + |
98 | 106 | it "sets release_task_id and release_branch from release_task_url" do |
99 | 107 | allow(Fastlane::Actions::ValidateInternalReleaseBumpAction).to receive(:find_release_task_if_needed).and_call_original |
100 | | - @params[:release_task_url] = "https://app.asana.com/0/1234567890/987654321" |
101 | | - Fastlane::Actions::ValidateInternalReleaseBumpAction.find_release_task_if_needed(@params) |
| 108 | + |
| 109 | + subject |
102 | 110 |
|
103 | 111 | expect(Fastlane::Helper::AsanaHelper).to have_received(:extract_asana_task_id).with(@params[:release_task_url], set_gha_output: false) |
104 | 112 | expect(Fastlane::Actions.other_action).to have_received(:ensure_git_branch).with(branch: "^release/.+$") |
|
108 | 116 | end |
109 | 117 |
|
110 | 118 | context "when release_task_url is not provided" do |
| 119 | + before do |
| 120 | + @params[:release_task_url] = nil |
| 121 | + end |
| 122 | + |
111 | 123 | it "runs AsanaFindReleaseTaskAction to find the release task" do |
112 | | - allow(Fastlane::Actions::ValidateInternalReleaseBumpAction).to receive(:find_release_task_if_needed).and_call_original |
113 | 124 | allow(Fastlane::Actions::AsanaFindReleaseTaskAction).to receive(:run).and_return({ release_task_id: "1234567890", release_branch: "release_branch_name" }) |
114 | | - Fastlane::Actions::ValidateInternalReleaseBumpAction.find_release_task_if_needed(@params) |
| 125 | + |
| 126 | + subject |
115 | 127 |
|
116 | 128 | expect(Fastlane::Actions::AsanaFindReleaseTaskAction).to have_received(:run).with( |
117 | 129 | asana_access_token: "secret-token", |
|
121 | 133 | expect(@params[:release_task_id]).to eq("1234567890") |
122 | 134 | expect(@params[:release_branch]).to eq("release_branch_name") |
123 | 135 | end |
| 136 | + |
| 137 | + context "when the release task is not found" do |
| 138 | + before do |
| 139 | + allow(Fastlane::Actions::AsanaFindReleaseTaskAction).to receive(:run).and_raise(FastlaneCore::Interface::FastlaneError.new) |
| 140 | + allow(Fastlane::UI).to receive(:important) |
| 141 | + end |
| 142 | + |
| 143 | + it "raises an error" do |
| 144 | + expect { subject }.to raise_error(FastlaneCore::Interface::FastlaneError) |
| 145 | + expect(Fastlane::UI).to have_received(:important).with("Regular release task not found. If this is an automatic bump after merging a hotfix branch, this failure is expected. Rerun this workflow from an internal release branch, providing the release task URL explicitly.") |
| 146 | + end |
| 147 | + end |
124 | 148 | end |
125 | 149 | end |
126 | 150 |
|
|
0 commit comments