|
| 1 | +import 'package:cli_script/cli_script.dart'; |
| 2 | +import 'package:file/file.dart'; |
| 3 | +import 'package:file/local.dart'; |
| 4 | +import 'package:test/test.dart'; |
| 5 | + |
| 6 | +import 'install_test.dart'; |
| 7 | + |
| 8 | +void main() { |
| 9 | + group('update', () { |
| 10 | + group("Update flutterw in git root", () { |
| 11 | + late Directory gitRootDir; |
| 12 | + late Directory appDir; |
| 13 | + |
| 14 | + tearDownAll(() { |
| 15 | + appDir.parent.deleteSync(recursive: true); |
| 16 | + }); |
| 17 | + setUpAll(() async { |
| 18 | + final dir = |
| 19 | + const LocalFileSystem().systemTempDirectory.createTempSync('root'); |
| 20 | + gitRootDir = appDir = dir.childDirectory('myApp'); |
| 21 | + assert(gitRootDir == appDir); |
| 22 | + |
| 23 | + // create git in appDir |
| 24 | + appDir.createSync(); |
| 25 | + await run("git init", workingDirectory: appDir.absolute.path); |
| 26 | + |
| 27 | + await runInstallScript( |
| 28 | + appDir: appDir.absolute.path, gitRootDir: gitRootDir.absolute.path); |
| 29 | + }); |
| 30 | + |
| 31 | + test('updates flutterw', () async { |
| 32 | + final flutterw = appDir.childFile('flutterw'); |
| 33 | + final content = flutterw.readAsStringSync(); |
| 34 | + await runInstallScript( |
| 35 | + appDir: appDir.absolute.path, gitRootDir: gitRootDir.absolute.path); |
| 36 | + |
| 37 | + final update = flutterw.readAsStringSync(); |
| 38 | + expect(update, isNot(content)); |
| 39 | + }); |
| 40 | + }); |
| 41 | + |
| 42 | + group("update in subdir", () { |
| 43 | + late Directory gitRootDir; |
| 44 | + late Directory appDir; |
| 45 | + |
| 46 | + tearDownAll(() { |
| 47 | + gitRootDir.deleteSync(recursive: true); |
| 48 | + }); |
| 49 | + |
| 50 | + setUpAll(() async { |
| 51 | + gitRootDir = |
| 52 | + const LocalFileSystem().systemTempDirectory.createTempSync('root'); |
| 53 | + // git repo in root, flutterw in appDir |
| 54 | + appDir = gitRootDir.childDirectory('myApp')..createSync(); |
| 55 | + |
| 56 | + await run("git init", workingDirectory: gitRootDir.absolute.path); |
| 57 | + await runInstallScript( |
| 58 | + appDir: appDir.absolute.path, gitRootDir: gitRootDir.absolute.path); |
| 59 | + }); |
| 60 | + |
| 61 | + test('updates flutterw', () async { |
| 62 | + final flutterw = appDir.childFile('flutterw'); |
| 63 | + final content = flutterw.readAsStringSync(); |
| 64 | + await runInstallScript( |
| 65 | + appDir: appDir.absolute.path, gitRootDir: gitRootDir.absolute.path); |
| 66 | + |
| 67 | + final update = flutterw.readAsStringSync(); |
| 68 | + expect(update, isNot(content)); |
| 69 | + }); |
| 70 | + }); |
| 71 | + }); |
| 72 | +} |
0 commit comments