feat(shorebird_cli): add flutterRevision setter to ShorebirdEnv (#1066)
This commit is contained in:
@@ -43,6 +43,17 @@ class ShorebirdEnv {
|
||||
).readAsStringSync().trim();
|
||||
}
|
||||
|
||||
set flutterRevision(String revision) {
|
||||
if (revision == flutterRevision) return;
|
||||
File(
|
||||
p.join(shorebirdRoot.path, 'bin', 'internal', 'flutter.version'),
|
||||
).writeAsStringSync(revision);
|
||||
final snapshot = File(
|
||||
p.join(shorebirdRoot.path, 'bin', 'cache', 'shorebird.snapshot'),
|
||||
);
|
||||
if (snapshot.existsSync()) snapshot.deleteSync();
|
||||
}
|
||||
|
||||
String get flutterRevision {
|
||||
return _flutterRevisionOverride ??
|
||||
File(
|
||||
|
||||
@@ -384,6 +384,66 @@ test-revision
|
||||
equals(override),
|
||||
);
|
||||
});
|
||||
|
||||
test('can be set', () {
|
||||
const newRevision = 'new-revision';
|
||||
const revision = '''
|
||||
|
||||
test-revision
|
||||
|
||||
\r\n
|
||||
''';
|
||||
final version = File(
|
||||
p.join(shorebirdRoot.path, 'bin', 'internal', 'flutter.version'),
|
||||
)
|
||||
..createSync(recursive: true)
|
||||
..writeAsStringSync(revision, flush: true);
|
||||
final snapshot = File(
|
||||
p.join(shorebirdRoot.path, 'bin', 'cache', 'shorebird.snapshot'))
|
||||
..createSync(recursive: true);
|
||||
|
||||
expect(
|
||||
runWithOverrides(() => shorebirdEnv.flutterRevision),
|
||||
'test-revision',
|
||||
);
|
||||
runWithOverrides(() => shorebirdEnv.flutterRevision = newRevision);
|
||||
expect(snapshot.existsSync(), isFalse);
|
||||
expect(version.readAsStringSync(), equals(newRevision));
|
||||
expect(
|
||||
runWithOverrides(() => shorebirdEnv.flutterRevision),
|
||||
newRevision,
|
||||
);
|
||||
});
|
||||
|
||||
test('setting to the same value does nothing', () {
|
||||
const newRevision = 'test-revision';
|
||||
const revision = '''
|
||||
|
||||
test-revision
|
||||
|
||||
\r\n
|
||||
''';
|
||||
final version = File(
|
||||
p.join(shorebirdRoot.path, 'bin', 'internal', 'flutter.version'),
|
||||
)
|
||||
..createSync(recursive: true)
|
||||
..writeAsStringSync(revision, flush: true);
|
||||
final snapshot = File(
|
||||
p.join(shorebirdRoot.path, 'bin', 'cache', 'shorebird.snapshot'))
|
||||
..createSync(recursive: true);
|
||||
|
||||
expect(
|
||||
runWithOverrides(() => shorebirdEnv.flutterRevision),
|
||||
'test-revision',
|
||||
);
|
||||
runWithOverrides(() => shorebirdEnv.flutterRevision = newRevision);
|
||||
expect(snapshot.existsSync(), isTrue);
|
||||
expect(version.readAsStringSync(), equals(revision));
|
||||
expect(
|
||||
runWithOverrides(() => shorebirdEnv.flutterRevision),
|
||||
newRevision,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
group('shorebirdEngineRevision', () {
|
||||
|
||||
Reference in New Issue
Block a user