Skip to content

Commit 97972c8

Browse files
committed
add tests for checking the version of the CLI we are using
1 parent 0fb4e84 commit 97972c8

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
lines changed

tools/fastlane-plugin/lib/fastlane/plugin/bugsnag/actions/upload_symbols_to_bugsnag.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def self.get_bugsnag_cli_path(params)
1616
bugsnag_cli_version = Gem::Version.new(`#{bugsnag_cli_path} --version`.scan(/(?:\d+\.?){3}/).first)
1717

1818
if bugsnag_cli_version < bundled_bugsnag_cli_version
19-
UI.user_error!("Your bugsnag-cli is outdated, please upgrade to at least version #{bundled_bugsnag_cli_version} and start your lane again!")
19+
UI.warning("Your bugsnag-cli is outdated. The current bugsnag-cli version is: #{bundled_bugsnag_cli_version}")
2020
end
2121
bugsnag_cli_path
2222
else

tools/fastlane-plugin/spec/bugsnag_upload_dsym_action_spec.rb

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,5 +159,30 @@ def run_with args
159159
expect(Kernel).to receive(:system).with("#{custom_cli_path} upload dsym --api-key #{api_key} --project-root #{Dir::pwd} \"#{FIXTURE_PATH}\"").and_return(true)
160160
run_with({dsym_path: FIXTURE_PATH, api_key: api_key, bugsnag_cli_path: custom_cli_path})
161161
end
162+
163+
it 'logs a warning when using an outdated CLI version' do
164+
cli_path = File.join(FIXTURE_PATH, 'dummy_bugsnag_cli.sh')
165+
bundled_bugsnag_cli_version = `#{BUGSNAG_CLI_PATH} --version`.strip
166+
allow(Fastlane::Actions::UploadSymbolsToBugsnagAction).to receive(:version_from_cli).and_return("1.0.0")
167+
allow(Fastlane::Actions::UploadSymbolsToBugsnagAction).to receive(:bundled_bugsnag_cli_version).and_return(bundled_bugsnag_cli_version)
168+
169+
expect(Fastlane::UI).to receive(:warning).with("Your bugsnag-cli is outdated. The current bugsnag-cli version is: #{bundled_bugsnag_cli_version}")
170+
expect(Kernel).to receive(:system).with("#{cli_path} upload dsym --project-root #{Dir::pwd} \"#{FIXTURE_PATH}\"").and_return(true)
171+
172+
run_with({dsym_path: FIXTURE_PATH, bugsnag_cli_path: cli_path})
173+
end
174+
175+
it 'logs doesnt log a warning when using an newer CLI version' do
176+
cli_version = "9.9.9"
177+
cli_path = File.join(FIXTURE_PATH, 'dummy_bugsnag_cli.sh')
178+
bundled_bugsnag_cli_version = `#{BUGSNAG_CLI_PATH} --version`.strip
179+
allow(Fastlane::Actions::UploadSymbolsToBugsnagAction).to receive(:version_from_cli).and_return(cli_version)
180+
allow(Fastlane::Actions::UploadSymbolsToBugsnagAction).to receive(:bundled_bugsnag_cli_version).and_return(bundled_bugsnag_cli_version)
181+
182+
expect(Fastlane::UI).not_to receive(:warning)
183+
184+
ENV['BUGSNAG_CLI_VERSION'] = cli_version
185+
run_with({dsym_path: FIXTURE_PATH, bugsnag_cli_path: cli_path})
186+
end
162187
end
163188
end
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
VERSION="1.0.0"
4+
5+
if [[ -n "$BUGSNAG_CLI_VERSION" ]]; then
6+
VERSION="$BUGSNAG_CLI_VERSION"
7+
fi
8+
9+
if [[ "$1" == "--version" ]]; then
10+
echo "Version: $VERSION"
11+
else
12+
echo "Usage: $0 [VERSION=x.y.z] --version"
13+
fi

0 commit comments

Comments
 (0)