added cleanContext (#93264)

* added cleanContext

* using async

* added one more test
This commit is contained in:
Alex
2021-11-08 17:34:03 -05:00
committed by GitHub
parent 550281e581
commit 9c1a87e627
2 changed files with 42 additions and 12 deletions

View File

@@ -15,6 +15,7 @@ void main() {
group('clean command', () {
const String flutterRoot = '/flutter';
const String checkoutsParentDirectory = '$flutterRoot/dev/tools/';
const String stateFilePath = '/state-file.json';
late MemoryFileSystem fileSystem;
late FakePlatform platform;
@@ -47,24 +48,36 @@ void main() {
});
test('throws if no state file found', () async {
const String stateFile = '/state-file.json';
await expectLater(
() async => runner.run(<String>[
'clean',
'--$kStateOption',
stateFile,
stateFilePath,
'--$kYesFlag',
]),
throwsExceptionWith(
'No persistent state file found at $stateFile',
'No persistent state file found at $stateFilePath',
),
);
});
test('deletes state file', () async {
final File stateFile = fileSystem.file('/state-file.json');
stateFile.writeAsStringSync('{}');
test('deletes an empty state file', () async {
final File stateFile = fileSystem.file(stateFilePath);
stateFile.writeAsStringSync('');
await runner.run(<String>[
'clean',
'--$kStateOption',
stateFile.path,
'--$kYesFlag',
]);
expect(stateFile.existsSync(), false);
});
test('deletes a state file with content', () async {
final File stateFile = fileSystem.file(stateFilePath);
stateFile.writeAsStringSync('{status: pending}');
await runner.run(<String>[
'clean',