Lazy cache 5: The Empire Strikes Back (#29986)

This commit is contained in:
Jonah Williams
2019-03-27 13:54:09 -07:00
committed by GitHub
parent 7f3485e388
commit 7d678f2adc
12 changed files with 374 additions and 191 deletions

View File

@@ -103,9 +103,9 @@ void main() {
when(artifact1.isUpToDate()).thenReturn(true);
when(artifact2.isUpToDate()).thenReturn(false);
final Cache cache = Cache(artifacts: <CachedArtifact>[artifact1, artifact2]);
await cache.updateAll();
verifyNever(artifact1.update());
verify(artifact2.update());
await cache.updateAll(<DevelopmentArtifact>{});
verifyNever(artifact1.update(<DevelopmentArtifact>{}));
verify(artifact2.update(<DevelopmentArtifact>{}));
});
testUsingContext('failed storage.googleapis.com download shows China warning', () async {
final CachedArtifact artifact1 = MockCachedArtifact();
@@ -114,18 +114,18 @@ void main() {
when(artifact2.isUpToDate()).thenReturn(false);
final MockInternetAddress address = MockInternetAddress();
when(address.host).thenReturn('storage.googleapis.com');
when(artifact1.update()).thenThrow(SocketException(
when(artifact1.update(<DevelopmentArtifact>{})).thenThrow(SocketException(
'Connection reset by peer',
address: address,
));
final Cache cache = Cache(artifacts: <CachedArtifact>[artifact1, artifact2]);
try {
await cache.updateAll();
await cache.updateAll(<DevelopmentArtifact>{});
fail('Mock thrown exception expected');
} catch (e) {
verify(artifact1.update());
verify(artifact1.update(<DevelopmentArtifact>{}));
// Don't continue when retrieval fails.
verifyNever(artifact2.update());
verifyNever(artifact2.update(<DevelopmentArtifact>{}));
expect(
testLogger.errorText,
contains('https://flutter.io/community/china'),

View File

@@ -42,7 +42,7 @@ void main() {
testUsingContext('honors shouldUpdateCache true', () async {
final DummyFlutterCommand flutterCommand = DummyFlutterCommand(shouldUpdateCache: true);
await flutterCommand.run();
verify(cache.updateAll()).called(1);
verify(cache.updateAll(any)).called(1);
},
overrides: <Type, Generator>{
Cache: () => cache,