Skip to content

Commit

Permalink
feat: add end to end test for no version code (#107)
Browse files Browse the repository at this point in the history
  • Loading branch information
tianhaoz95 authored Mar 14, 2021
1 parent 7b54e1c commit 8bd41f1
Show file tree
Hide file tree
Showing 3 changed files with 133 additions and 3 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/sentry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ jobs:
- name: install dependencies
run: bundle install
- name: sanity checks
run: bundle exec rake
- name: run tests
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
run: bundle exec fastlane test
run: bundle exec rake
- name: run tests
run: |
bundle exec fastlane test
bundle exec fastlane test_no_version_code
98 changes: 98 additions & 0 deletions example/variants/no_version_code.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
name: photochatapp
description: A mini donkey to help carry messages securely and secretly.

# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.6

environment:
sdk: ">=2.1.0 <3.0.0"

dependencies:
flutter:
sdk: flutter
flutter_localizations:
sdk: flutter

# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.2

# third party packages
image_picker: ^0.6.3+1
image_gallery_saver: ^1.2.2
esys_flutter_share: ^1.0.2
image:
permission_handler: ^4.4.0+hotfix.2
encrypt: ^4.0.0
provider: ^4.0.4
http: ^0.12.0+4
intl: ^0.16.0
device_info: ^0.4.2+1

dev_dependencies:
flutter_test:
sdk: flutter
flutter_driver:
sdk: flutter
test: any
mockito: ^4.1.1
path_provider: ^1.6.0
intl_translation: ^0.17.9

# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec

# The following section is specific to Flutter.
flutter:
assets:
- "assets/photo_placeholder.png"
- "assets/loading_deer.gif"
- "assets/loading_donkey.gif"
- "assets/loading_husky.gif"
- "assets/message_logo.png"
- "assets/rabbits_clapping.gif"
- "assets/bear_bye.gif"
- "assets/in_love_corgi_long.gif"
- "assets/programming_corgi.gif"
- "assets/test_images/corgi.png"
- "assets/test_images/encrypted_corgi.png"

# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
uses-material-design: true

# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware.

# For details regarding adding assets from package dependencies, see
# https://flutter.dev/assets-and-images/#from-packages

# To add custom fonts to your application, add a fonts section here,
# in this "flutter" section. Each entry in this list should have a
# "family" key with the font family name, and a "fonts" key with a
# list giving the asset and other descriptors for the font. For
# example:
# fonts:
# - family: Schyler
# fonts:
# - asset: fonts/Schyler-Regular.ttf
# - asset: fonts/Schyler-Italic.ttf
# style: italic
# - family: Trajan Pro
# fonts:
# - asset: fonts/TrajanPro.ttf
# - asset: fonts/TrajanPro_Bold.ttf
# weight: 700
#
# For details regarding fonts from package dependencies,
# see https://flutter.dev/custom-fonts/#from-packages
30 changes: 30 additions & 0 deletions fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,33 @@ lane :test do
)
end
end

lane :test_no_version_code do
version_info = flutter_version(
pubspec_location: './example/variants/no_version_code.yaml',
should_omit_version_code: true
)
puts version_info
# Tests if the version code retrieved from the pubspec.yaml matches
version_code = version_info['version_code']
correct_version_code = 'NOT_FOUND'
if version_code != correct_version_code
UI.user_error!(
'version_code mismatched, expect '
.concat(correct_version_code)
.concat(', got ')
.concat(version_code)
)
end
# Tests if the version name retrieved from the pubspec.yaml matches
version_name = version_info['version_name']
expected_version_name = '1.0.6'
if version_name != expected_version_name
UI.user_error!(
'version_name mismatched, expect '
.concat(expected_version_name)
.concat(', got ')
.concat(version_name)
)
end
end

0 comments on commit 8bd41f1

Please sign in to comment.