Skip to content

Commit a99305e

Browse files
authored
Support group_alias parameter for remove_testers_action. (#313)
This removes the testers from only the specified group, but doesn't delete them from the project.
1 parent 3443307 commit a99305e

File tree

2 files changed

+45
-7
lines changed

2 files changed

+45
-7
lines changed

lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_remove_testers_action.rb

+16-7
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,15 @@ def self.run(params)
2626
UI.user_error!("A maximum of 1000 testers can be removed at a time.")
2727
end
2828

29-
UI.message("⏳ Removing #{emails.count} testers from project #{params[:project_number]}...")
30-
31-
count = fad_api_client.remove_testers(params[:project_number], emails)
32-
33-
UI.success("✅ #{count} tester(s) removed successfully.")
29+
if blank?(params[:group_alias])
30+
UI.message("⏳ Removing #{emails.count} testers from project #{params[:project_number]}...")
31+
count = fad_api_client.remove_testers(params[:project_number], emails)
32+
UI.success("✅ #{count} tester(s) removed successfully.")
33+
else
34+
UI.message("⏳ Removing #{emails.count} testers from group #{params[:group_alias]}...")
35+
fad_api_client.remove_testers_from_group(params[:project_number], params[:group_alias], emails)
36+
UI.success("✅ Tester(s) removed successfully.")
37+
end
3438
end
3539

3640
def self.description
@@ -55,14 +59,19 @@ def self.available_options
5559
optional: false),
5660
FastlaneCore::ConfigItem.new(key: :emails,
5761
env_name: "FIREBASEAPPDISTRO_REMOVE_TESTERS_EMAILS",
58-
description: "Comma separated list of tester emails to be deleted. A maximum of 1000 testers can be deleted at a time",
62+
description: "Comma separated list of tester emails to be deleted (or removed from a group if a group alias is specified). A maximum of 1000 testers can be deleted/removed at a time",
5963
optional: true,
6064
type: String),
6165
FastlaneCore::ConfigItem.new(key: :file,
6266
env_name: "FIREBASEAPPDISTRO_REMOVE_TESTERS_FILE",
63-
description: "Path to a file containing a comma separated list of tester emails to be deleted. A maximum of 1000 testers can be deleted at a time",
67+
description: "Path to a file containing a comma separated list of tester emails to be deleted (or removed from a group if a group alias is specified). A maximum of 1000 testers can be deleted/removed at a time",
6468
optional: true,
6569
type: String),
70+
FastlaneCore::ConfigItem.new(key: :group_alias,
71+
env_name: "FIREBASEAPPDISTRO_REMOVE_TESTERS_GROUP_ALIAS",
72+
description: "Alias of the group to remove the specified testers from. Testers will not be deleted from the project",
73+
optional: true,
74+
type: String),
6675
FastlaneCore::ConfigItem.new(key: :service_credentials_file,
6776
description: "Path to Google service credentials file",
6877
optional: true,

spec/firebase_app_distribution_remove_testers_action_spec.rb

+29
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,34 @@
5353

5454
action.run({ project_number: project_number, file: path })
5555
end
56+
57+
it 'removes testers only from the specified group when group_alias is specified' do
58+
project_number = 1
59+
60+
path = 'path/to/file'
61+
fake_file = double('file')
62+
group_alias = 'group_alias'
63+
allow(File).to receive(:open)
64+
.with(path)
65+
.and_return(fake_file)
66+
allow(fake_file).to receive(:read).and_return(emails)
67+
expect_any_instance_of(Fastlane::Client::FirebaseAppDistributionApiClient).not_to(receive(:remove_testers))
68+
expect_any_instance_of(Fastlane::Client::FirebaseAppDistributionApiClient).to receive(:remove_testers_from_group).with(project_number, group_alias, emails.split(','))
69+
action.run({ project_number: project_number, file: path, group_alias: group_alias })
70+
end
71+
72+
it 'does not makes any remove_testers_from_group calls when group_alias is not specified' do
73+
project_number = 1
74+
75+
path = 'path/to/file'
76+
fake_file = double('file')
77+
allow(File).to receive(:open)
78+
.with(path)
79+
.and_return(fake_file)
80+
allow(fake_file).to receive(:read).and_return(emails)
81+
expect_any_instance_of(Fastlane::Client::FirebaseAppDistributionApiClient).to receive(:remove_testers).with(project_number, emails.split(','))
82+
expect_any_instance_of(Fastlane::Client::FirebaseAppDistributionApiClient).not_to(receive(:remove_testers_from_group))
83+
action.run({ project_number: project_number, file: path })
84+
end
5685
end
5786
end

0 commit comments

Comments
 (0)