-
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.
Merge pull request #5 from phntmxyz/modifications
- Loading branch information
Showing
6 changed files
with
211 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,4 +23,7 @@ jobs: | |
- name: Install dependencies | ||
run: dart pub get | ||
- name: Run tests | ||
run: dart test | ||
run: | | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "Dash" | ||
dart test |
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
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,73 @@ | ||
import 'package:phntmxyz_bump_version_sidekick_plugin/phntmxyz_bump_version_sidekick_plugin.dart'; | ||
import 'package:sidekick_core/sidekick_core.dart'; | ||
import 'package:sidekick_test/sidekick_test.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
void main() { | ||
test('executes sync modification', () async { | ||
await insideFakeProjectWithSidekick((dir) async { | ||
await dir.file('pubspec.yaml').appendString('\nversion: 1.2.3'); | ||
final readme = dir.file('README.md'); | ||
readme.writeAsStringSync(''' | ||
# Package | ||
```yaml | ||
dependencies: | ||
my_package: ^1.2.3 | ||
``` | ||
'''); | ||
final runner = initializeSidekick( | ||
dartSdkPath: fakeDartSdk().path, | ||
); | ||
runner.addCommand( | ||
BumpVersionCommand() | ||
..addModification((package, oldVersion, newVersion) { | ||
final versionRegex = RegExp(r'my_package: \^(.+)'); | ||
final update = readme.readAsStringSync().replaceFirst( | ||
versionRegex, | ||
'my_package: ^${newVersion.canonicalizedVersion}', | ||
); | ||
readme.writeAsStringSync(update); | ||
}), | ||
); | ||
await runner.run(['bump-version', '--minor']); | ||
|
||
expect(readme.readAsStringSync(), contains('my_package: ^1.3.0')); | ||
}); | ||
}); | ||
|
||
test('executes async modification', () async { | ||
await insideFakeProjectWithSidekick((dir) async { | ||
await dir.file('pubspec.yaml').appendString('\nversion: 1.2.3'); | ||
final readme = dir.file('README.md'); | ||
readme.writeAsStringSync(''' | ||
# Package | ||
```yaml | ||
dependencies: | ||
my_package: ^1.2.3 | ||
``` | ||
'''); | ||
final runner = initializeSidekick( | ||
dartSdkPath: fakeDartSdk().path, | ||
); | ||
runner.addCommand( | ||
BumpVersionCommand() | ||
..addModification((package, oldVersion, newVersion) async { | ||
// make it really async | ||
await Future.delayed(const Duration(milliseconds: 200)); | ||
|
||
final versionRegex = RegExp(r'my_package: \^(.+)'); | ||
final update = readme.readAsStringSync().replaceFirst( | ||
versionRegex, | ||
'my_package: ^${newVersion.canonicalizedVersion}', | ||
); | ||
readme.writeAsStringSync(update); | ||
}), | ||
); | ||
await runner.run(['bump-version', '--minor']); | ||
|
||
expect(readme.readAsStringSync(), contains('my_package: ^1.3.0')); | ||
}); | ||
}); | ||
} |
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