Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ upload_to_amazon_appstore(
| metadata_path | Path to the directory containing the metadata files | ./fastlane/metadata/android |
| changes_not_sent_for_review | Indicates that the changes in this edit will not be reviewed until they are explicitly sent for review from the Amazon Appstore Console UI | false |
| overwrite_upload | Whether to allow overwriting an existing upload | false |
| overwrite_upload_mode | Upload strategy when overwrite_upload is true. Can be 'new' (delete existing edit and create new) or 'reuse' (reuse existing edit) | new |
| timeout | Timeout for read, open (in seconds) | 300 |
* = default value is dependent on the user's system

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ def self.run(params) # rubocop:disable Metrics/PerceivedComplexity
elsif params[:overwrite_upload_mode] == "reuse"
UI.message("Retrieving active edit (overwrite_upload: true, overwrite_upload_mode: reuse)...")
begin
edit_id, _ = Helper::AmazonAppstoreHelper.get_edits(
edit_id, = Helper::AmazonAppstoreHelper.get_edits(
app_id: params[:package_name],
token: token
)
rescue StandardError => e
UI.error(e.message)
UI.abort_with_message!("Failed to get edit_id (overwrite_upload: true, overwrite_upload_mode: new)")
UI.abort_with_message!("Failed to get edit_id (overwrite_upload: true, overwrite_upload_mode: reuse)")
end
UI.message("No active edit") if edit_id.nil?
end
Expand Down
43 changes: 41 additions & 2 deletions spec/actions/upload_to_amazon_appstore_action_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
allow(Fastlane::Helper::AmazonAppstoreHelper).to receive(:setup).and_return(nil)
allow(Fastlane::Helper::AmazonAppstoreHelper).to receive(:token).and_return('token')
allow(Fastlane::Helper::AmazonAppstoreHelper).to receive(:delete_edits_if_exists).and_return(nil)
allow(Fastlane::Helper::AmazonAppstoreHelper).to receive(:get_edits).and_return([nil, nil])
allow(Fastlane::Helper::AmazonAppstoreHelper).to receive(:create_edits).and_return('edit_id')
allow(Fastlane::Helper::AmazonAppstoreHelper).to receive(:replace_apks).and_return([{ version_code: 100, apk_id: 'apk_id_1' }])
allow(Fastlane::Helper::AmazonAppstoreHelper).to receive(:update_listings_for_multiple_apks).and_return(nil)
Expand Down Expand Up @@ -121,7 +122,7 @@
end

context 'overwrite_upload' do
context 'enabled' do
context 'enabled with mode new (default)' do
let(:params) do
{
client_id: 'client_id',
Expand All @@ -132,6 +133,7 @@
metadata_path: './fastlane/metadata/android',
changes_not_sent_for_review: false,
overwrite_upload: true,
overwrite_upload_mode: 'new',
timeout: 300
}
end
Expand All @@ -148,6 +150,43 @@
end
end

context 'enabled with mode reuse' do
let(:params) do
{
client_id: 'client_id',
client_secret: 'client_secret',
package_name: 'package_name',
apk: 'apk',
skip_upload_changelogs: false,
metadata_path: './fastlane/metadata/android',
changes_not_sent_for_review: false,
overwrite_upload: true,
overwrite_upload_mode: 'reuse',
timeout: 300
}
end

before do
allow(Fastlane::Helper::AmazonAppstoreHelper).to receive(:get_edits).and_return(['edit_id', 'etag'])
end

it 'should call get_edits' do
Fastlane::Actions::UploadToAmazonAppstoreAction.run(params)
expect(Fastlane::Helper::AmazonAppstoreHelper).to have_received(:get_edits)
end

it 'should not call delete_edits_if_exists' do
Fastlane::Actions::UploadToAmazonAppstoreAction.run(params)
expect(Fastlane::Helper::AmazonAppstoreHelper).not_to have_received(:delete_edits_if_exists)
end

it 'should call UI.success' do
allow(Fastlane::UI).to receive(:success).and_return(true)
Fastlane::Actions::UploadToAmazonAppstoreAction.run(params)
expect(Fastlane::UI).to have_received(:success).once
end
end

context 'disabled' do
let(:params) do
{
Expand Down Expand Up @@ -310,7 +349,7 @@

describe '#available_options' do
it 'should return options' do
expect(Fastlane::Actions::UploadToAmazonAppstoreAction.available_options.size).to eq(10)
expect(Fastlane::Actions::UploadToAmazonAppstoreAction.available_options.size).to eq(11)
end
end

Expand Down