forked from fluttercommunity/flutter_launcher_icons
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: checking version number is matching one in pubspec.yaml
- Loading branch information
1 parent
3f30632
commit 2713188
Showing
4 changed files
with
42 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import 'dart:io'; | ||
|
||
import 'package:yaml/yaml.dart'; | ||
|
||
/// helper class for parsing the contents of pubspec file | ||
class PubspecParser { | ||
|
||
/// ensures unnamed constructor cannot be used as this class should only have | ||
/// static methods | ||
PubspecParser._(); | ||
|
||
/// parses the pubspec located at [path] to map | ||
static Map toMap(String path) { | ||
final File file = File(path); | ||
final String yamlString = file.readAsStringSync(); | ||
final Map yamlMap = loadYaml(yamlString); | ||
return yamlMap; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import 'package:flutter_launcher_icons/pubspec_parser.dart'; | ||
import 'package:flutter_launcher_icons/src/version.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
void main() { | ||
/// this helps avoid an issue where the pubspec version has been increased but | ||
/// build runner has not been run to up the version which is displayed | ||
/// when flutter_launcher_icons is run | ||
test('package version is correct', () { | ||
final yamlMap = PubspecParser.toMap('pubspec.yaml'); | ||
final yamlVersion = yamlMap['version'] as String; | ||
expect( | ||
yamlVersion, | ||
packageVersion, | ||
reason: 'Versions are not matching. Solution: Run build runner to ' | ||
'updated generated version value.', | ||
); | ||
}); | ||
} |