diff --git a/.rubocop.yml b/.rubocop.yml index 5380e6c..245d2bc 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,4 +1,6 @@ --- +require: +- rubocop/require_tools Style/MultipleComparison: Enabled: false Style/PercentLiteralDelimiters: @@ -152,9 +154,6 @@ Style/IfInsideElse: Enabled: false Style/CollectionMethods: Enabled: false -CrossPlatform/ForkUsage: - Exclude: - - "**/plugins/template/**/*" Style/MethodCallWithArgsParentheses: Enabled: true IgnoredMethods: diff --git a/lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_action.rb b/lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_action.rb index dcd2196..0cb0e49 100644 --- a/lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_action.rb +++ b/lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_action.rb @@ -1,8 +1,9 @@ require 'fastlane/action' +require 'fastlane_core' require 'open3' require 'shellwords' require 'googleauth' -require 'google/apis/firebaseappdistribution_v1' +require_relative '../helper/firebase_app_distribution_apis' require_relative '../helper/firebase_app_distribution_helper' require_relative '../helper/firebase_app_distribution_error_message' require_relative '../helper/firebase_app_distribution_auth_client' @@ -158,7 +159,9 @@ def self.xcode_archive_path # the same lane return nil if lane_platform == :android + # rubocop:disable Require/MissingRequireStatement Actions.lane_context[SharedValues::XCODEBUILD_ARCHIVE] + # rubocop:enable Require/MissingRequireStatement end def self.lane_platform @@ -174,6 +177,7 @@ def self.platform_from_app_id(app_id) end end + # rubocop:disable Require/MissingRequireStatement def self.get_binary_path(platform, params) if platform == :ios return params[:ipa_path] || @@ -198,6 +202,7 @@ def self.get_binary_path(platform, params) UI.error("Unable to determine binary path for unsupported platform #{platform}.") nil end + # rubocop:enable Require/MissingRequireStatement def self.get_upload_timeout(params) if params[:upload_timeout] @@ -236,7 +241,9 @@ def self.aab_info_name(app_name) def self.release_notes(params) release_notes_param = get_value_from_value_or_file(params[:release_notes], params[:release_notes_file]) + # rubocop:disable Require/MissingRequireStatement release_notes_param || Actions.lane_context[SharedValues::FL_CHANGELOG] + # rubocop:enable Require/MissingRequireStatement end def self.poll_upload_release_operation(client, operation, binary_type) @@ -506,7 +513,7 @@ def self.available_options type: String), FastlaneCore::ConfigItem.new(key: :groups_file, env_name: "FIREBASEAPPDISTRO_GROUPS_FILE", - description: "Path to file containing group aliases used for distribution, separated by commas", + description: "Path to file containing group aliases used for distribution, separated by commas or newlines", optional: true, type: String), FastlaneCore::ConfigItem.new(key: :testers, @@ -516,7 +523,7 @@ def self.available_options type: String), FastlaneCore::ConfigItem.new(key: :testers_file, env_name: "FIREBASEAPPDISTRO_TESTERS_FILE", - description: "Path to file containing email addresses of testers, separated by commas", + description: "Path to file containing email addresses of testers, separated by commas or newlines", optional: true, type: String), FastlaneCore::ConfigItem.new(key: :release_notes, @@ -533,12 +540,13 @@ def self.available_options # Release Testing FastlaneCore::ConfigItem.new(key: :test_devices, env_name: "FIREBASEAPPDISTRO_TEST_DEVICES", - description: "List of devices to run automated tests on, in the format 'model=,version=,locale=,orientation=;model=,...'. Run 'gcloud firebase test android|ios models list' to see available devices. Note: This feature is in beta", + description: "List of devices (separated by semicolons) to run automated tests on, in the format 'model=,version=,locale=,orientation=;model=,...'. Run 'gcloud firebase test android|ios models list' to see available devices. Note: This feature is in beta", optional: true, type: String), FastlaneCore::ConfigItem.new(key: :test_devices_file, env_name: "FIREBASEAPPDISTRO_TEST_DEVICES_FILE", - description: "Path to file containing a list of devices to run automated tests on, in the format 'model=,version=,locale=,orientation=;model=,...'. Run 'gcloud firebase test android|ios models list' to see available devices. Note: This feature is in beta", + description: "Path to file containing a list of devices (sepatated by semicolons or newlines) to run automated tests on, in the format 'model=,version=,locale=,orientation=;model=,...'. " \ + "Run 'gcloud firebase test android|ios models list' to see available devices. Note: This feature is in beta", optional: true, type: String), FastlaneCore::ConfigItem.new(key: :test_username, diff --git a/lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_add_testers_action.rb b/lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_add_testers_action.rb index 2739de7..88be03a 100644 --- a/lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_add_testers_action.rb +++ b/lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_add_testers_action.rb @@ -1,7 +1,9 @@ require 'fastlane/action' +require 'fastlane_core' require 'fastlane_core/ui/ui' -require 'google/apis/firebaseappdistribution_v1' +require_relative '../helper/firebase_app_distribution_apis' require_relative '../helper/firebase_app_distribution_helper' +require_relative '../helper/firebase_app_distribution_error_message' require_relative '../helper/firebase_app_distribution_auth_client' module Fastlane diff --git a/lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_create_group_action.rb b/lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_create_group_action.rb index 17c5cd1..471bbb4 100644 --- a/lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_create_group_action.rb +++ b/lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_create_group_action.rb @@ -1,7 +1,9 @@ require 'fastlane/action' +require 'fastlane_core' require 'fastlane_core/ui/ui' -require 'google/apis/firebaseappdistribution_v1' +require_relative '../helper/firebase_app_distribution_apis' require_relative '../helper/firebase_app_distribution_helper' +require_relative '../helper/firebase_app_distribution_error_message' require_relative '../helper/firebase_app_distribution_auth_client' module Fastlane diff --git a/lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_delete_group_action.rb b/lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_delete_group_action.rb index 02983b3..568e966 100644 --- a/lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_delete_group_action.rb +++ b/lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_delete_group_action.rb @@ -1,7 +1,9 @@ require 'fastlane/action' +require 'fastlane_core' require 'fastlane_core/ui/ui' -require 'google/apis/firebaseappdistribution_v1' +require_relative '../helper/firebase_app_distribution_apis' require_relative '../helper/firebase_app_distribution_helper' +require_relative '../helper/firebase_app_distribution_error_message' require_relative '../helper/firebase_app_distribution_auth_client' module Fastlane diff --git a/lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_get_latest_release.rb b/lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_get_latest_release.rb index 6fd796e..db1de93 100644 --- a/lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_get_latest_release.rb +++ b/lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_get_latest_release.rb @@ -1,6 +1,8 @@ require 'fastlane/action' -require 'google/apis/firebaseappdistribution_v1' +require 'fastlane_core' +require_relative '../helper/firebase_app_distribution_apis' require_relative '../helper/firebase_app_distribution_auth_client' +require_relative '../helper/firebase_app_distribution_error_message' require_relative '../helper/firebase_app_distribution_helper' module Fastlane diff --git a/lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_get_udids.rb b/lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_get_udids.rb index bf3e57c..e0c5bf7 100644 --- a/lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_get_udids.rb +++ b/lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_get_udids.rb @@ -1,8 +1,9 @@ require 'fastlane/action' +require 'fastlane_core' require 'open3' require 'shellwords' require 'googleauth' -require 'google/apis/firebaseappdistribution_v1alpha' +require_relative '../helper/firebase_app_distribution_apis' require_relative '../helper/firebase_app_distribution_helper' require_relative '../helper/firebase_app_distribution_error_message' require_relative '../helper/firebase_app_distribution_auth_client' diff --git a/lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_remove_testers_action.rb b/lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_remove_testers_action.rb index fb0c1e6..a2c9164 100644 --- a/lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_remove_testers_action.rb +++ b/lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_remove_testers_action.rb @@ -1,7 +1,9 @@ require 'fastlane/action' +require 'fastlane_core' require 'fastlane_core/ui/ui' -require 'google/apis/firebaseappdistribution_v1' +require_relative '../helper/firebase_app_distribution_apis' require_relative '../helper/firebase_app_distribution_helper' +require_relative '../helper/firebase_app_distribution_error_message' require_relative '../helper/firebase_app_distribution_auth_client' module Fastlane diff --git a/lib/fastlane/plugin/firebase_app_distribution/helper/firebase_app_distribution_apis.rb b/lib/fastlane/plugin/firebase_app_distribution/helper/firebase_app_distribution_apis.rb new file mode 100644 index 0000000..3ab923b --- /dev/null +++ b/lib/fastlane/plugin/firebase_app_distribution/helper/firebase_app_distribution_apis.rb @@ -0,0 +1,2 @@ +require 'google/apis/firebaseappdistribution_v1' +require 'google/apis/firebaseappdistribution_v1alpha' diff --git a/lib/fastlane/plugin/firebase_app_distribution/helper/firebase_app_distribution_auth_client.rb b/lib/fastlane/plugin/firebase_app_distribution/helper/firebase_app_distribution_auth_client.rb index 18ab536..bdfaee4 100644 --- a/lib/fastlane/plugin/firebase_app_distribution/helper/firebase_app_distribution_auth_client.rb +++ b/lib/fastlane/plugin/firebase_app_distribution/helper/firebase_app_distribution_auth_client.rb @@ -1,5 +1,6 @@ require 'googleauth' require 'fastlane_core/ui/ui' +require_relative './firebase_app_distribution_error_message' module Fastlane UI = FastlaneCore::UI unless Fastlane.const_defined?("UI") diff --git a/lib/fastlane/plugin/firebase_app_distribution/helper/firebase_app_distribution_helper.rb b/lib/fastlane/plugin/firebase_app_distribution/helper/firebase_app_distribution_helper.rb index a7e699d..174ec5a 100644 --- a/lib/fastlane/plugin/firebase_app_distribution/helper/firebase_app_distribution_helper.rb +++ b/lib/fastlane/plugin/firebase_app_distribution/helper/firebase_app_distribution_helper.rb @@ -1,5 +1,8 @@ require 'fastlane_core/ui/ui' require 'cfpropertylist' +require 'google/apis/core' +require 'google/apis/options' +require_relative './firebase_app_distribution_error_message' module Fastlane UI = FastlaneCore::UI unless Fastlane.const_defined?("UI") diff --git a/spec/firebase_app_distribution_action_spec.rb b/spec/firebase_app_distribution_action_spec.rb index 2013e58..7808607 100644 --- a/spec/firebase_app_distribution_action_spec.rb +++ b/spec/firebase_app_distribution_action_spec.rb @@ -211,9 +211,6 @@ end describe '#run' do - V1Api = Google::Apis::FirebaseappdistributionV1 - V1AlphaApi = Google::Apis::FirebaseappdistributionV1alpha - let(:params) do { app: ios_app_id, @@ -250,7 +247,7 @@ before { allow(File).to receive(:exist?).with('debug.aab').and_return(true) } it 'raises user error if request returns a 404' do - allow_any_instance_of(V1Api::FirebaseAppDistributionService) + allow_any_instance_of(Google::Apis::FirebaseappdistributionV1::FirebaseAppDistributionService) .to receive(:get_project_app_aab_info) .and_raise(Google::Apis::Error.new({}, status_code: '404')) @@ -260,10 +257,10 @@ end def stub_get_aab_info(integration_state = 'INTEGRATED') - allow_any_instance_of(V1Api::FirebaseAppDistributionService) + allow_any_instance_of(Google::Apis::FirebaseappdistributionV1::FirebaseAppDistributionService) .to receive(:get_project_app_aab_info) .with("#{android_app_name}/aabInfo") - .and_return(V1Api::GoogleFirebaseAppdistroV1AabInfo.new(integration_state: integration_state)) + .and_return(Google::Apis::FirebaseappdistributionV1::GoogleFirebaseAppdistroV1AabInfo.new(integration_state: integration_state)) end it 'raises error if play account is not linked' do @@ -320,7 +317,7 @@ def stub_get_aab_info(integration_state = 'INTEGRATED') end it 'raises permission denied error if upload returns a 403', :focus do - allow_any_instance_of(V1Api::FirebaseAppDistributionService) + allow_any_instance_of(Google::Apis::FirebaseappdistributionV1::FirebaseAppDistributionService) .to receive(:http) .and_raise(Google::Apis::Error.new('error', status_code: '403')) @@ -330,7 +327,7 @@ def stub_get_aab_info(integration_state = 'INTEGRATED') end it 'raises error with status code if upload returns an unexpected error', :focus do - allow_any_instance_of(V1Api::FirebaseAppDistributionService) + allow_any_instance_of(Google::Apis::FirebaseappdistributionV1::FirebaseAppDistributionService) .to receive(:http) .and_raise(Google::Apis::Error.new({}, status_code: '404')) @@ -341,13 +338,13 @@ def stub_get_aab_info(integration_state = 'INTEGRATED') it 'crashes if it exceeds polling threshold' do stub_const('Fastlane::Actions::FirebaseAppDistributionAction::UPLOAD_MAX_POLLING_RETRIES', 0) - allow_any_instance_of(V1Api::FirebaseAppDistributionService) + allow_any_instance_of(Google::Apis::FirebaseappdistributionV1::FirebaseAppDistributionService) .to receive(:http) .and_return({ name: 'operation-name' }.to_json) - allow_any_instance_of(V1Api::FirebaseAppDistributionService) + allow_any_instance_of(Google::Apis::FirebaseappdistributionV1::FirebaseAppDistributionService) .to receive(:get_project_app_release_operation) .with('operation-name') - .and_return(V1Api::GoogleLongrunningOperation.new( + .and_return(Google::Apis::FirebaseappdistributionV1::GoogleLongrunningOperation.new( done: false )) @@ -363,12 +360,13 @@ def stub_get_aab_info(integration_state = 'INTEGRATED') let(:release) { { name: "release-name", displayVersion: 'display-version' } } before do - allow_any_instance_of(V1Api::FirebaseAppDistributionService) + stub_const('Fastlane::Actions::FirebaseAppDistributionAction::UPLOAD_POLLING_INTERVAL_SECONDS', 0) + allow_any_instance_of(Google::Apis::FirebaseappdistributionV1::FirebaseAppDistributionService) .to receive(:http) .and_return({ name: 'operation-name', result: release }.to_json) - allow_any_instance_of(V1Api::FirebaseAppDistributionService) + allow_any_instance_of(Google::Apis::FirebaseappdistributionV1::FirebaseAppDistributionService) .to receive(:get_project_app_release_operation) - .and_return(V1Api::GoogleLongrunningOperation.new( + .and_return(Google::Apis::FirebaseappdistributionV1::GoogleLongrunningOperation.new( done: true, response: { 'release' => release @@ -377,8 +375,8 @@ def stub_get_aab_info(integration_state = 'INTEGRATED') end it 'returns release and updates FIREBASE_APP_DISTRO_RELEASE' do - expect_any_instance_of(V1Api::FirebaseAppDistributionService).to_not(receive(:distribute_project_app_release)) - expect_any_instance_of(V1Api::FirebaseAppDistributionService).to_not(receive(:patch_project_app_release)) + expect_any_instance_of(Google::Apis::FirebaseappdistributionV1::FirebaseAppDistributionService).to_not(receive(:distribute_project_app_release)) + expect_any_instance_of(Google::Apis::FirebaseappdistributionV1::FirebaseAppDistributionService).to_not(receive(:patch_project_app_release)) action.run({ app: android_app_id, @@ -390,7 +388,7 @@ def stub_get_aab_info(integration_state = 'INTEGRATED') describe 'when distributing to testers' do it 'raises error if request returns a 400' do - allow_any_instance_of(V1Api::FirebaseAppDistributionService) + allow_any_instance_of(Google::Apis::FirebaseappdistributionV1::FirebaseAppDistributionService) .to receive(:distribute_project_app_release) .and_raise(Google::Apis::Error.new({}, status_code: '400')) @@ -405,16 +403,16 @@ def stub_get_aab_info(integration_state = 'INTEGRATED') end it 'distributes to testers, returns release and updates FIREBASE_APP_DISTRO_RELEASE' do - allow_any_instance_of(V1Api::FirebaseAppDistributionService) + allow_any_instance_of(Google::Apis::FirebaseappdistributionV1::FirebaseAppDistributionService) .to receive(:distribute_project_app_release) - expect_any_instance_of(V1Api::FirebaseAppDistributionService) + expect_any_instance_of(Google::Apis::FirebaseappdistributionV1::FirebaseAppDistributionService) .to receive(:distribute_project_app_release) do |_, release_name, request| expect(request.tester_emails).to eq(%w[user1@example.com user2@example.com]) # Response will fail if tester_emails or group_aliases field is nil # it sets absent values to empty arrays expect(request.group_aliases).to eq([]) end - expect_any_instance_of(V1Api::FirebaseAppDistributionService) + expect_any_instance_of(Google::Apis::FirebaseappdistributionV1::FirebaseAppDistributionService) .to_not(receive(:patch_project_app_release)) returned_release = action.run({ @@ -428,16 +426,16 @@ def stub_get_aab_info(integration_state = 'INTEGRATED') end it 'distributes to groups, returns release and updates FIREBASE_APP_DISTRO_RELEASE' do - allow_any_instance_of(V1Api::FirebaseAppDistributionService) + allow_any_instance_of(Google::Apis::FirebaseappdistributionV1::FirebaseAppDistributionService) .to receive(:distribute_project_app_release) - expect_any_instance_of(V1Api::FirebaseAppDistributionService) + expect_any_instance_of(Google::Apis::FirebaseappdistributionV1::FirebaseAppDistributionService) .to receive(:distribute_project_app_release) do |_, release_name, request| expect(request.group_aliases).to eq(%w[test-group-1 test-group-2]) # Response will fail if tester_emails or group_aliases field is nil # it sets absent values to empty arrays expect(request.tester_emails).to eq([]) end - expect_any_instance_of(V1Api::FirebaseAppDistributionService) + expect_any_instance_of(Google::Apis::FirebaseappdistributionV1::FirebaseAppDistributionService) .to_not(receive(:patch_project_app_release)) returned_release = action.run({ @@ -451,14 +449,14 @@ def stub_get_aab_info(integration_state = 'INTEGRATED') end it 'distributes to groups and testers, returns release and updates FIREBASE_APP_DISTRO_RELEASE' do - allow_any_instance_of(V1Api::FirebaseAppDistributionService) + allow_any_instance_of(Google::Apis::FirebaseappdistributionV1::FirebaseAppDistributionService) .to receive(:distribute_project_app_release) - expect_any_instance_of(V1Api::FirebaseAppDistributionService) + expect_any_instance_of(Google::Apis::FirebaseappdistributionV1::FirebaseAppDistributionService) .to receive(:distribute_project_app_release) do |_, release_name, request| expect(request.group_aliases).to eq(%w[test-group-1 test-group-2]) expect(request.tester_emails).to eq(%w[user1@example.com user2@example.com]) end - expect_any_instance_of(V1Api::FirebaseAppDistributionService) + expect_any_instance_of(Google::Apis::FirebaseappdistributionV1::FirebaseAppDistributionService) .to_not(receive(:patch_project_app_release)) returned_release = action.run({ @@ -475,7 +473,7 @@ def stub_get_aab_info(integration_state = 'INTEGRATED') describe 'when updating release notes' do it 'raises error if request returns a 400' do - allow_any_instance_of(V1Api::FirebaseAppDistributionService) + allow_any_instance_of(Google::Apis::FirebaseappdistributionV1::FirebaseAppDistributionService) .to receive(:patch_project_app_release) .and_raise(Google::Apis::Error.new({}, status_code: '400', body: 'release notes too long')) @@ -490,10 +488,10 @@ def stub_get_aab_info(integration_state = 'INTEGRATED') it 'distributes to groups and testers, returns release and updates FIREBASE_APP_DISTRO_RELEASE' do updated_release = release.merge({ releaseNotes: { text: 'updated' } }) - allow_any_instance_of(V1Api::FirebaseAppDistributionService) + allow_any_instance_of(Google::Apis::FirebaseappdistributionV1::FirebaseAppDistributionService) .to receive(:patch_project_app_release) - .and_return(V1Api::GoogleFirebaseAppdistroV1Release.from_json(updated_release.to_json)) - allow_any_instance_of(V1Api::FirebaseAppDistributionService) + .and_return(Google::Apis::FirebaseappdistributionV1::GoogleFirebaseAppdistroV1Release.from_json(updated_release.to_json)) + allow_any_instance_of(Google::Apis::FirebaseappdistributionV1::FirebaseAppDistributionService) .to receive(:distribute_project_app_release) returned_release = action.run({ @@ -509,7 +507,7 @@ def stub_get_aab_info(integration_state = 'INTEGRATED') describe 'when performing automated tests' do before do - allow_any_instance_of(V1Api::FirebaseAppDistributionService) + allow_any_instance_of(Google::Apis::FirebaseappdistributionV1::FirebaseAppDistributionService) .to receive(:distribute_project_app_release) end @@ -570,7 +568,7 @@ def stub_get_aab_info(integration_state = 'INTEGRATED') end it 'passes login credential' do - allow_any_instance_of(V1AlphaApi::FirebaseAppDistributionService).to receive(:create_project_app_release_test) do |_, release_name, request| + allow_any_instance_of(Google::Apis::FirebaseappdistributionV1alpha::FirebaseAppDistributionService).to receive(:create_project_app_release_test) do |_, release_name, request| expect(request.login_credential.username).to eq('username') expect(request.login_credential.password).to eq('password') expect(request.login_credential.field_hints).to be_nil @@ -586,7 +584,7 @@ def stub_get_aab_info(integration_state = 'INTEGRATED') end it 'passes login credential with field hints' do - allow_any_instance_of(V1AlphaApi::FirebaseAppDistributionService).to receive(:create_project_app_release_test) do |_, release_name, request| + allow_any_instance_of(Google::Apis::FirebaseappdistributionV1alpha::FirebaseAppDistributionService).to receive(:create_project_app_release_test) do |_, release_name, request| expect(request.login_credential.username).to eq('username') expect(request.login_credential.password).to eq('password') expect(request.login_credential.field_hints.username_resource_name).to eq('username_resource') @@ -615,7 +613,7 @@ def stub_get_aab_info(integration_state = 'INTEGRATED') end it 'passes device information' do - allow_any_instance_of(V1AlphaApi::FirebaseAppDistributionService).to receive(:create_project_app_release_test) do |_, release_name, request| + allow_any_instance_of(Google::Apis::FirebaseappdistributionV1alpha::FirebaseAppDistributionService).to receive(:create_project_app_release_test) do |_, release_name, request| expect(request.device_executions[0].device.model).to eq('model1') expect(request.device_executions[0].device.version).to eq('version1') expect(request.device_executions[0].device.orientation).to eq('orientation1') diff --git a/spec/firebase_app_distribution_add_testers_action_spec.rb b/spec/firebase_app_distribution_add_testers_action_spec.rb index 055f20d..87362a2 100644 --- a/spec/firebase_app_distribution_add_testers_action_spec.rb +++ b/spec/firebase_app_distribution_add_testers_action_spec.rb @@ -3,16 +3,14 @@ describe Fastlane::Actions::FirebaseAppDistributionAddTestersAction do let(:action) { Fastlane::Actions::FirebaseAppDistributionAddTestersAction } describe '#run' do - V1ApiService = Google::Apis::FirebaseappdistributionV1::FirebaseAppDistributionService - let(:project_number) { 1 } let(:emails) { '1@e.mail,2@e.mail' } before(:each) do allow(action).to receive(:get_authorization).and_return('fake-auth-token') - allow_any_instance_of(V1ApiService) + allow_any_instance_of(Google::Apis::FirebaseappdistributionV1::FirebaseAppDistributionService) .to receive(:batch_project_tester_add) - allow_any_instance_of(V1ApiService) + allow_any_instance_of(Google::Apis::FirebaseappdistributionV1::FirebaseAppDistributionService) .to receive(:batch_project_group_join) end @@ -34,7 +32,7 @@ end it 'raises a user error if request returns a 400' do - allow_any_instance_of(V1ApiService) + allow_any_instance_of(Google::Apis::FirebaseappdistributionV1::FirebaseAppDistributionService) .to receive(:batch_project_tester_add) .and_raise(Google::Apis::Error.new({}, status_code: '400')) @@ -44,7 +42,7 @@ end it 'raises a user error if request returns a 404' do - allow_any_instance_of(V1ApiService) + allow_any_instance_of(Google::Apis::FirebaseappdistributionV1::FirebaseAppDistributionService) .to receive(:batch_project_tester_add) .and_raise(Google::Apis::Error.new({}, status_code: '404')) @@ -54,7 +52,7 @@ end it 'raises a user error if request returns a 429' do - allow_any_instance_of(V1ApiService) + allow_any_instance_of(Google::Apis::FirebaseappdistributionV1::FirebaseAppDistributionService) .to receive(:batch_project_tester_add) .and_raise(Google::Apis::Error.new({}, status_code: '429')) @@ -64,7 +62,7 @@ end it 'crashes for unhandled error' do - allow_any_instance_of(V1ApiService) + allow_any_instance_of(Google::Apis::FirebaseappdistributionV1::FirebaseAppDistributionService) .to receive(:batch_project_tester_add) .and_raise(Google::Apis::Error.new({}, status_code: '500')) @@ -76,7 +74,7 @@ it 'succeeds and makes call with value from emails param' do path = 'path/to/file' - expect_any_instance_of(V1ApiService) + expect_any_instance_of(Google::Apis::FirebaseappdistributionV1::FirebaseAppDistributionService) .to receive(:batch_project_tester_add) do |_, parent, request| expect(parent).to eq("projects/#{project_number}") expect(request.emails).to eq(emails.split(',')) @@ -93,7 +91,7 @@ .and_return(fake_file) allow(fake_file).to receive(:read).and_return(emails) - expect_any_instance_of(V1ApiService) + expect_any_instance_of(Google::Apis::FirebaseappdistributionV1::FirebaseAppDistributionService) .to receive(:batch_project_tester_add) do |_, parent, request| expect(parent).to eq("projects/#{project_number}") expect(request.emails).to eq(emails.split(',')) @@ -103,7 +101,7 @@ end it 'does not makes any batch_project_group_join calls when group_alias is not specified' do - expect_any_instance_of(V1ApiService) + expect_any_instance_of(Google::Apis::FirebaseappdistributionV1::FirebaseAppDistributionService) .not_to(receive(:batch_project_group_join)) action.run({ project_number: project_number, emails: emails }) @@ -113,7 +111,7 @@ let(:group_alias) { 'group-alias' } it 'raises a user error if request returns a 400' do - allow_any_instance_of(V1ApiService) + allow_any_instance_of(Google::Apis::FirebaseappdistributionV1::FirebaseAppDistributionService) .to receive(:batch_project_group_join) .and_raise(Google::Apis::Error.new({}, status_code: '400')) @@ -123,7 +121,7 @@ end it 'raises a user error if request returns a 404' do - allow_any_instance_of(V1ApiService) + allow_any_instance_of(Google::Apis::FirebaseappdistributionV1::FirebaseAppDistributionService) .to receive(:batch_project_group_join) .and_raise(Google::Apis::Error.new({}, status_code: '404')) @@ -133,7 +131,7 @@ end it 'raises a user error if request returns a 429' do - allow_any_instance_of(V1ApiService) + allow_any_instance_of(Google::Apis::FirebaseappdistributionV1::FirebaseAppDistributionService) .to receive(:batch_project_group_join) .and_raise(Google::Apis::Error.new({}, status_code: '429')) @@ -143,7 +141,7 @@ end it 'crashes for unhandled error' do - allow_any_instance_of(V1ApiService) + allow_any_instance_of(Google::Apis::FirebaseappdistributionV1::FirebaseAppDistributionService) .to receive(:batch_project_group_join) .and_raise(Google::Apis::Error.new({}, status_code: '500')) @@ -153,7 +151,7 @@ end it 'adds testers to the specified group' do - expect_any_instance_of(V1ApiService) + expect_any_instance_of(Google::Apis::FirebaseappdistributionV1::FirebaseAppDistributionService) .to receive(:batch_project_group_join) do |_, name, request| expect(name).to eq("projects/#{project_number}/groups/#{group_alias}") expect(request.emails).to eq(emails.split(',')) diff --git a/spec/firebase_app_distribution_create_group_action_spec.rb b/spec/firebase_app_distribution_create_group_action_spec.rb index c93db3d..30b9614 100644 --- a/spec/firebase_app_distribution_create_group_action_spec.rb +++ b/spec/firebase_app_distribution_create_group_action_spec.rb @@ -1,12 +1,9 @@ require 'fastlane/action' -require 'google/apis/firebaseappdistribution_v1' describe Fastlane::Actions::FirebaseAppDistributionCreateGroupAction do let(:action) { Fastlane::Actions::FirebaseAppDistributionCreateGroupAction } describe '#run' do - V1ApiService = Google::Apis::FirebaseappdistributionV1::FirebaseAppDistributionService - let(:project_number) { 1 } let(:group_alias) { 'group_alias' } let(:display_name) { 'Display name' } @@ -26,7 +23,7 @@ end it 'raises a user error if request returns a 400' do - allow_any_instance_of(V1ApiService) + allow_any_instance_of(Google::Apis::FirebaseappdistributionV1::FirebaseAppDistributionService) .to receive(:create_project_group) .and_raise(Google::Apis::Error.new({}, status_code: '400')) @@ -36,7 +33,7 @@ end it 'raises a user error if request returns a 404' do - allow_any_instance_of(V1ApiService) + allow_any_instance_of(Google::Apis::FirebaseappdistributionV1::FirebaseAppDistributionService) .to receive(:create_project_group) .and_raise(Google::Apis::Error.new({}, status_code: '404')) @@ -46,7 +43,7 @@ end it 'crashes if error is unhandled' do - allow_any_instance_of(V1ApiService) + allow_any_instance_of(Google::Apis::FirebaseappdistributionV1::FirebaseAppDistributionService) .to receive(:create_project_group) .and_raise(Google::Apis::Error.new({}, status_code: '500')) @@ -60,9 +57,9 @@ name: "projects/#{project_number}/groups/#{group_alias}", display_name: display_name ) - allow_any_instance_of(V1ApiService) + allow_any_instance_of(Google::Apis::FirebaseappdistributionV1::FirebaseAppDistributionService) .to receive(:create_project_group) - expect_any_instance_of(V1ApiService) + expect_any_instance_of(Google::Apis::FirebaseappdistributionV1::FirebaseAppDistributionService) .to receive(:create_project_group) do |_, parent, expected_group, args| expect(parent).to eq("projects/#{project_number}") expect(expected_group.name).to eq(group.name) diff --git a/spec/firebase_app_distribution_delete_group_action_spec.rb b/spec/firebase_app_distribution_delete_group_action_spec.rb index 1e97007..e8c5977 100644 --- a/spec/firebase_app_distribution_delete_group_action_spec.rb +++ b/spec/firebase_app_distribution_delete_group_action_spec.rb @@ -3,8 +3,6 @@ describe Fastlane::Actions::FirebaseAppDistributionDeleteGroupAction do let(:action) { Fastlane::Actions::FirebaseAppDistributionDeleteGroupAction } describe '#run' do - V1ApiService = Google::Apis::FirebaseappdistributionV1::FirebaseAppDistributionService - let(:project_number) { 1 } let(:group_alias) { 'group-alias' } @@ -18,7 +16,7 @@ end it 'raises a user error if request returns a 404' do - allow_any_instance_of(V1ApiService) + allow_any_instance_of(Google::Apis::FirebaseappdistributionV1::FirebaseAppDistributionService) .to receive(:delete_project_group) .and_raise(Google::Apis::Error.new({}, status_code: '404')) @@ -28,7 +26,7 @@ end it 'crashes if error is unhandled' do - allow_any_instance_of(V1ApiService) + allow_any_instance_of(Google::Apis::FirebaseappdistributionV1::FirebaseAppDistributionService) .to receive(:delete_project_group) .and_raise(Google::Apis::Error.new({}, status_code: '500')) @@ -38,9 +36,9 @@ end it 'succeeds and makes calls with the correct values' do - allow_any_instance_of(V1ApiService) + allow_any_instance_of(Google::Apis::FirebaseappdistributionV1::FirebaseAppDistributionService) .to receive(:delete_project_group) - expect_any_instance_of(V1ApiService) + expect_any_instance_of(Google::Apis::FirebaseappdistributionV1::FirebaseAppDistributionService) .to receive(:delete_project_group) .with("projects/#{project_number}/groups/#{group_alias}") action.run({ project_number: project_number, alias: group_alias }) diff --git a/spec/firebase_app_distribution_get_latest_release_spec.rb b/spec/firebase_app_distribution_get_latest_release_spec.rb index c2f2b55..616beec 100644 --- a/spec/firebase_app_distribution_get_latest_release_spec.rb +++ b/spec/firebase_app_distribution_get_latest_release_spec.rb @@ -1,18 +1,15 @@ require 'fastlane/action' -require 'google/apis/firebaseappdistribution_v1' describe Fastlane::Actions::FirebaseAppDistributionGetLatestReleaseAction do let(:action) { Fastlane::Actions::FirebaseAppDistributionGetLatestReleaseAction } describe '#run' do - V1Api = Google::Apis::FirebaseappdistributionV1 - before(:each) do allow(action).to receive(:get_authorization).and_return(double("creds")) end it 'returns nil if the app does not have any releases' do - response = V1Api::GoogleFirebaseAppdistroV1ListReleasesResponse.new - allow_any_instance_of(V1Api::FirebaseAppDistributionService) + response = Google::Apis::FirebaseappdistributionV1::GoogleFirebaseAppdistroV1ListReleasesResponse.new + allow_any_instance_of(Google::Apis::FirebaseappdistributionV1::FirebaseAppDistributionService) .to receive(:list_project_app_releases) .with('projects/1234567890/apps/1:1234567890:ios:321abc456def7890', page_size: 1) .and_return(response) @@ -22,11 +19,11 @@ end it 'returns the release if the app has at least one release' do - response = V1Api::GoogleFirebaseAppdistroV1ListReleasesResponse.new( + response = Google::Apis::FirebaseappdistributionV1::GoogleFirebaseAppdistroV1ListReleasesResponse.new( releases: [ - V1Api::GoogleFirebaseAppdistroV1Release.new( + Google::Apis::FirebaseappdistributionV1::GoogleFirebaseAppdistroV1Release.new( name: "projects/1234567890/apps/1:1234567890:ios:321abc456def7890/releases/0a1b2c3d4", - release_notes: V1Api::GoogleFirebaseAppdistroV1ReleaseNotes.new( + release_notes: Google::Apis::FirebaseappdistributionV1::GoogleFirebaseAppdistroV1ReleaseNotes.new( text: "Here are some release notes!" ), display_version: "1.2.3", @@ -38,7 +35,7 @@ ) ] ) - allow_any_instance_of(V1Api::FirebaseAppDistributionService) + allow_any_instance_of(Google::Apis::FirebaseappdistributionV1::FirebaseAppDistributionService) .to receive(:list_project_app_releases) .with('projects/1234567890/apps/1:1234567890:ios:321abc456def7890', page_size: 1) .and_return(response) @@ -61,9 +58,9 @@ end it 'returns the release with release notes set to nil' do - response = V1Api::GoogleFirebaseAppdistroV1ListReleasesResponse.new( + response = Google::Apis::FirebaseappdistributionV1::GoogleFirebaseAppdistroV1ListReleasesResponse.new( releases: [ - V1Api::GoogleFirebaseAppdistroV1Release.new( + Google::Apis::FirebaseappdistributionV1::GoogleFirebaseAppdistroV1Release.new( name: "projects/1234567890/apps/1:1234567890:ios:321abc456def7890/releases/0a1b2c3d4", display_version: "1.2.3", build_version: "10", @@ -74,7 +71,7 @@ ) ] ) - allow_any_instance_of(V1Api::FirebaseAppDistributionService) + allow_any_instance_of(Google::Apis::FirebaseappdistributionV1::FirebaseAppDistributionService) .to receive(:list_project_app_releases) .with('projects/1234567890/apps/1:1234567890:ios:321abc456def7890', page_size: 1) .and_return(response) diff --git a/spec/firebase_app_distribution_get_udids_spec.rb b/spec/firebase_app_distribution_get_udids_spec.rb index 3c4f236..aabe246 100644 --- a/spec/firebase_app_distribution_get_udids_spec.rb +++ b/spec/firebase_app_distribution_get_udids_spec.rb @@ -1,5 +1,4 @@ require 'fastlane/action' -require 'google/apis/firebaseappdistribution_v1alpha' describe Fastlane::Actions::FirebaseAppDistributionGetUdidsAction do let(:action) { Fastlane::Actions::FirebaseAppDistributionGetUdidsAction } @@ -9,29 +8,27 @@ let(:output_file_path) { '/path/to/output/file.txt' } describe '#run' do - V1alphaApi = Google::Apis::FirebaseappdistributionV1alpha - before do allow(action).to receive(:get_authorization).and_return(double("creds")) end describe 'when there are testers with udids' do before(:each) do - response = V1alphaApi::GoogleFirebaseAppdistroV1alphaGetTesterUdidsResponse.new( + response = Google::Apis::FirebaseappdistributionV1alpha::GoogleFirebaseAppdistroV1alphaGetTesterUdidsResponse.new( tester_udids: [ - V1alphaApi::GoogleFirebaseAppdistroV1alphaTesterUdid.new( + Google::Apis::FirebaseappdistributionV1alpha::GoogleFirebaseAppdistroV1alphaTesterUdid.new( udid: 'device-udid-1', name: 'device-name-1', platform: 'ios' ), - V1alphaApi::GoogleFirebaseAppdistroV1alphaTesterUdid.new( + Google::Apis::FirebaseappdistributionV1alpha::GoogleFirebaseAppdistroV1alphaTesterUdid.new( udid: 'device-udid-2', name: 'device-name-2', platform: 'ios' ) ] ) - allow_any_instance_of(V1alphaApi::FirebaseAppDistributionService) + allow_any_instance_of(Google::Apis::FirebaseappdistributionV1alpha::FirebaseAppDistributionService) .to receive(:get_project_tester_udids) .with('projects/1234567890') .and_return(response) @@ -53,10 +50,10 @@ describe 'when there are no testers with udids' do before(:each) do - response = V1alphaApi::GoogleFirebaseAppdistroV1alphaGetTesterUdidsResponse.new( + response = Google::Apis::FirebaseappdistributionV1alpha::GoogleFirebaseAppdistroV1alphaGetTesterUdidsResponse.new( tester_udids: [] ) - allow_any_instance_of(V1alphaApi::FirebaseAppDistributionService) + allow_any_instance_of(Google::Apis::FirebaseappdistributionV1alpha::FirebaseAppDistributionService) .to receive(:get_project_tester_udids) .with('projects/1234567890') .and_return(response) diff --git a/spec/firebase_app_distribution_remove_testers_action_spec.rb b/spec/firebase_app_distribution_remove_testers_action_spec.rb index 56be860..13ed8a4 100644 --- a/spec/firebase_app_distribution_remove_testers_action_spec.rb +++ b/spec/firebase_app_distribution_remove_testers_action_spec.rb @@ -4,19 +4,17 @@ describe Fastlane::Actions::FirebaseAppDistributionRemoveTestersAction do let(:action) { Fastlane::Actions::FirebaseAppDistributionRemoveTestersAction } describe '#run' do - V1ApiService = Google::Apis::FirebaseappdistributionV1::FirebaseAppDistributionService - let(:project_number) { 1 } let(:emails) { '1@e.mail,2@e.mail' } before(:each) do allow(action).to receive(:get_authorization).and_return('fake-auth-token') - allow_any_instance_of(V1ApiService) + allow_any_instance_of(Google::Apis::FirebaseappdistributionV1::FirebaseAppDistributionService) .to receive(:batch_project_tester_remove) .and_return(Google::Apis::FirebaseappdistributionV1::GoogleFirebaseAppdistroV1BatchRemoveTestersResponse.new( emails: emails.split(',') )) - allow_any_instance_of(V1ApiService) + allow_any_instance_of(Google::Apis::FirebaseappdistributionV1::FirebaseAppDistributionService) .to receive(:batch_project_group_leave) allow(FastlaneCore::UI).to receive(:success) end @@ -39,7 +37,7 @@ end it 'raises a user error if request returns a 404' do - allow_any_instance_of(V1ApiService) + allow_any_instance_of(Google::Apis::FirebaseappdistributionV1::FirebaseAppDistributionService) .to receive(:batch_project_tester_remove) .and_raise(Google::Apis::Error.new({}, status_code: '404')) @@ -49,7 +47,7 @@ end it 'crashes if error is unhandled' do - allow_any_instance_of(V1ApiService) + allow_any_instance_of(Google::Apis::FirebaseappdistributionV1::FirebaseAppDistributionService) .to receive(:batch_project_tester_remove) .and_raise(Google::Apis::Error.new({}, status_code: '500')) @@ -59,7 +57,7 @@ end it 'succeeds and makes call with value from emails param' do - expect_any_instance_of(V1ApiService) + expect_any_instance_of(Google::Apis::FirebaseappdistributionV1::FirebaseAppDistributionService) .to receive(:batch_project_tester_remove) { |_, parent, request| expect(parent).to eq("projects/#{project_number}") expect(request.emails).to eq(emails.split(',')) @@ -79,7 +77,7 @@ .and_return(fake_file) allow(fake_file).to receive(:read).and_return(emails) - expect_any_instance_of(V1ApiService) + expect_any_instance_of(Google::Apis::FirebaseappdistributionV1::FirebaseAppDistributionService) .to receive(:batch_project_tester_remove) { |_, parent, request| expect(parent).to eq("projects/#{project_number}") expect(request.emails).to eq(emails.split(',')) @@ -92,7 +90,7 @@ end it 'does not makes any batch_project_group_leave calls when group_alias is not specified' do - expect_any_instance_of(V1ApiService) + expect_any_instance_of(Google::Apis::FirebaseappdistributionV1::FirebaseAppDistributionService) .to_not(receive(:batch_project_group_leave)) action.run({ project_number: project_number, emails: emails }) @@ -102,7 +100,7 @@ let(:group_alias) { 'group-alias' } it 'raises a user error if request returns a 400' do - allow_any_instance_of(V1ApiService) + allow_any_instance_of(Google::Apis::FirebaseappdistributionV1::FirebaseAppDistributionService) .to receive(:batch_project_group_leave) .and_raise(Google::Apis::Error.new({}, status_code: '400')) @@ -112,7 +110,7 @@ end it 'raises a user error if request returns a 404' do - allow_any_instance_of(V1ApiService) + allow_any_instance_of(Google::Apis::FirebaseappdistributionV1::FirebaseAppDistributionService) .to receive(:batch_project_group_leave) .and_raise(Google::Apis::Error.new({}, status_code: '404')) @@ -122,7 +120,7 @@ end it 'crashes if error is unhandled' do - allow_any_instance_of(V1ApiService) + allow_any_instance_of(Google::Apis::FirebaseappdistributionV1::FirebaseAppDistributionService) .to receive(:batch_project_group_leave) .and_raise(Google::Apis::Error.new({}, status_code: '500')) @@ -132,9 +130,9 @@ end it 'removes testers from the specified group' do - expect_any_instance_of(V1ApiService) + expect_any_instance_of(Google::Apis::FirebaseappdistributionV1::FirebaseAppDistributionService) .to_not(receive(:batch_project_tester_remove)) - expect_any_instance_of(V1ApiService) + expect_any_instance_of(Google::Apis::FirebaseappdistributionV1::FirebaseAppDistributionService) .to receive(:batch_project_group_leave) do |_, name, request| expect(name).to eq("projects/#{project_number}/groups/#{group_alias}") expect(request.emails).to eq(emails.split(','))