Skip to content

Commit

Permalink
Handle missing github handle
Browse files Browse the repository at this point in the history
  • Loading branch information
jaceklyp committed Sep 5, 2024
1 parent 91ae0b6 commit e28812f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def self.run(params)
asana_user_id = user_mapping[github_handle]

if asana_user_id.nil? || asana_user_id.to_s.empty?
UI.warning("Asana User ID not found for GitHub handle: #{github_handle}")
UI.message("Asana User ID not found for GitHub handle: #{github_handle}")
else
Helper::GitHubActionsHelper.set_output("asana_user_id", asana_user_id)
asana_user_id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ def self.run(params)
task_id = AsanaExtractTaskIdAction.run(task_url: task_url)
assignee_id = AsanaExtractTaskAssigneeAction.run(task_id: task_id, asana_access_token: token)
else
if github_handle.to_s.empty?
UI.user_error!("Github handle cannot be empty for manual release")
return
end
assignee_id = AsanaGetUserIdForGithubHandleAction.run(github_handle: github_handle, asana_access_token: token)
end

Expand Down
6 changes: 3 additions & 3 deletions spec/asana_get_user_id_for_github_handle_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@
end

it "shows warning when handle does not exist" do
expect(Fastlane::UI).to receive(:warning).with("Asana User ID not found for GitHub handle: chicken")
expect(Fastlane::UI).to receive(:message).with("Asana User ID not found for GitHub handle: chicken")
test_action("chicken")
end

it "shows warning when handle is nil" do
expect(Fastlane::UI).to receive(:warning).with("Asana User ID not found for GitHub handle: pigeon")
expect(Fastlane::UI).to receive(:message).with("Asana User ID not found for GitHub handle: pigeon")
test_action("pigeon")
end

it "shows warning when handle is empty" do
expect(Fastlane::UI).to receive(:warning).with("Asana User ID not found for GitHub handle: hawk")
expect(Fastlane::UI).to receive(:message).with("Asana User ID not found for GitHub handle: hawk")
test_action("hawk")
end
end
Expand Down
5 changes: 5 additions & 0 deletions spec/asana_log_message_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@
test_action(task_url: task_url, comment: comment, is_scheduled_release: false, github_handle: github_handle)
end

it "raises an error when github handle is empty and is manual release" do
expect(Fastlane::UI).to receive(:user_error!).with("Github handle cannot be empty for manual release")
test_action(task_url: task_url, comment: comment, is_scheduled_release: false, github_handle: "")
end

it "adds a assignee as a follower to the automation task" do
expect(@asana_client_tasks).to receive(:add_followers_for_task).with(task_gid: automation_subtask_id, followers: [assignee_id])
test_action(task_url: task_url, comment: comment, is_scheduled_release: false, github_handle: github_handle)
Expand Down

0 comments on commit e28812f

Please sign in to comment.