Skip to content

Commit

Permalink
[fastlane][tests] add tests for CLIToolsDistributor (#20315)
Browse files Browse the repository at this point in the history
* [fastlane] Add a test for CLI for map_aliased_tools

* Add TOOL_ALIASES hash with mapping

* Generate cases for all tool aliases

* Run rubocop
  • Loading branch information
lucgrabowski authored May 25, 2022
1 parent f2e4805 commit 1238c39
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 20 deletions.
17 changes: 1 addition & 16 deletions fastlane/lib/fastlane/cli_tools_distributor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,22 +127,7 @@ def take_off
end

def map_aliased_tools(tool_name)
map = {
"get_certificates": "cert",
"upload_to_app_store": "deliver",
"frame_screenshots": "frameit",
"build_app": "gym",
"build_ios_app": "gym",
"build_mac_app": "gym",
"sync_code_signing": "match",
"get_push_certificate": "pem",
"check_app_store_metadata": "precheck",
"capture_android_screenshots": "screengrab",
"get_provisioning_profile": "sigh",
"capture_ios_screenshots": "snapshot",
"upload_to_play_store": "supply"
}
return map[tool_name&.to_sym] || tool_name
Fastlane::TOOL_ALIASES[tool_name&.to_sym] || tool_name
end

# Since loading dotenv should respect additional environments passed using
Expand Down
16 changes: 16 additions & 0 deletions fastlane/lib/fastlane/tools.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,20 @@ module Fastlane
"Screengrabfile",
"Snapshotfile"
]

TOOL_ALIASES = {
"get_certificates": "cert",
"upload_to_app_store": "deliver",
"frame_screenshots": "frameit",
"build_app": "gym",
"build_ios_app": "gym",
"build_mac_app": "gym",
"sync_code_signing": "match",
"get_push_certificate": "pem",
"check_app_store_metadata": "precheck",
"capture_android_screenshots": "screengrab",
"get_provisioning_profile": "sigh",
"capture_ios_screenshots": "snapshot",
"upload_to_play_store": "supply"
}
end
17 changes: 13 additions & 4 deletions fastlane/spec/cli_tools_distributor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,20 @@
Fastlane::CLIToolsDistributor.take_off
end
end
end

it "passes nil when --env is not specified" do
FastlaneSpec::Env.with_ARGV(["lanes"]) do
expect(Fastlane::Helper::DotenvHelper).to receive(:load_dot_env).with(nil)
Fastlane::CLIToolsDistributor.take_off
describe "map_aliased_tools" do
before do
require 'fastlane'
end

it "returns nil when tool_name is nil" do
expect(Fastlane::CLIToolsDistributor.map_aliased_tools(nil)).to eq(nil)
end

Fastlane::TOOL_ALIASES.each do |key, value|
it "returns #{value} when tool_name is #{key}" do
expect(Fastlane::CLIToolsDistributor.map_aliased_tools(key)).to eq(value)
end
end
end
Expand Down

0 comments on commit 1238c39

Please sign in to comment.