From 47d225d52f86752d14fc44cc03c2894869672f8b Mon Sep 17 00:00:00 2001 From: gkc Date: Fri, 15 Sep 2023 10:48:44 +0100 Subject: [PATCH] style: run dart format in at_lookup --- .../cacheable_secondary_address_finder.dart | 3 +- .../test/connection_management_test.dart | 21 ++++++--- .../test/secondary_address_cache_test.dart | 44 +++++++++++-------- 3 files changed, 42 insertions(+), 26 deletions(-) diff --git a/packages/at_lookup/lib/src/cache/cacheable_secondary_address_finder.dart b/packages/at_lookup/lib/src/cache/cacheable_secondary_address_finder.dart index 6c70f5f0..c2ce09de 100644 --- a/packages/at_lookup/lib/src/cache/cacheable_secondary_address_finder.dart +++ b/packages/at_lookup/lib/src/cache/cacheable_secondary_address_finder.dart @@ -130,7 +130,8 @@ class SecondaryUrlFinder { final int _rootPort; late final AtLookupSecureSocketFactory _socketFactory; - SecondaryUrlFinder(this._rootDomain, this._rootPort, {AtLookupSecureSocketFactory? socketFactory}) { + SecondaryUrlFinder(this._rootDomain, this._rootPort, + {AtLookupSecureSocketFactory? socketFactory}) { _socketFactory = socketFactory ?? AtLookupSecureSocketFactory(); } diff --git a/packages/at_lookup/test/connection_management_test.dart b/packages/at_lookup/test/connection_management_test.dart index 9a8501b5..46de1a5e 100644 --- a/packages/at_lookup/test/connection_management_test.dart +++ b/packages/at_lookup/test/connection_management_test.dart @@ -30,7 +30,8 @@ void main() { when(() => mockSocketFactory.createSocket('test.test.test', '12345', any())) .thenAnswer((invocation) { - return Future.value(createMockAtServerSocket('test.test.test', 12345)); + return Future.value( + createMockAtServerSocket('test.test.test', 12345)); }); }); @@ -95,7 +96,8 @@ void main() { test( 'test message listener closes connection' ' when socket listener onDone is called', () async { - OutboundConnection oc = OutboundConnectionImpl(createMockAtServerSocket('test.test.test', 12345)); + OutboundConnection oc = OutboundConnectionImpl( + createMockAtServerSocket('test.test.test', 12345)); OutboundMessageListener oml = OutboundMessageListener(oc); expect((oc.getSocket() as MockSecureSocket).destroyed, false); expect(oc.metaData?.isClosed, false); @@ -107,7 +109,8 @@ void main() { test( 'test message listener closes connection' ' when socket listener onError is called', () async { - OutboundConnection oc = OutboundConnectionImpl(createMockAtServerSocket('test.test.test', 12345)); + OutboundConnection oc = OutboundConnectionImpl( + createMockAtServerSocket('test.test.test', 12345)); OutboundMessageListener oml = OutboundMessageListener(oc); expect((oc.getSocket() as MockSecureSocket).destroyed, false); expect(oc.metaData?.isClosed, false); @@ -117,7 +120,8 @@ void main() { }); test('test can safely call connection.close() repeatedly', () async { - OutboundConnection oc = OutboundConnectionImpl(createMockAtServerSocket('test.test.test', 12345)); + OutboundConnection oc = OutboundConnectionImpl( + createMockAtServerSocket('test.test.test', 12345)); OutboundMessageListener oml = OutboundMessageListener(oc); expect((oc.getSocket() as MockSecureSocket).destroyed, false); expect(oc.metaData?.isClosed, false); @@ -136,7 +140,8 @@ void main() { test( 'test that OutboundMessageListener.closeConnection will call' ' connection.close if the connection is idle', () async { - OutboundConnection oc = OutboundConnectionImpl(createMockAtServerSocket('test.test.test', 12345)); + OutboundConnection oc = OutboundConnectionImpl( + createMockAtServerSocket('test.test.test', 12345)); OutboundMessageListener oml = OutboundMessageListener(oc); expect((oc.getSocket() as MockSecureSocket).destroyed, false); expect(oc.metaData?.isClosed, false); @@ -156,7 +161,8 @@ void main() { test( 'test that OutboundMessageListener.closeConnection will not call' ' connection.close if already marked closed', () async { - OutboundConnection oc = OutboundConnectionImpl(createMockAtServerSocket('test.test.test', 12345)); + OutboundConnection oc = OutboundConnectionImpl( + createMockAtServerSocket('test.test.test', 12345)); OutboundMessageListener oml = OutboundMessageListener(oc); expect((oc.getSocket() as MockSecureSocket).destroyed, false); oc.metaData!.isClosed = true; @@ -170,7 +176,8 @@ void main() { test( 'test that OutboundMessageListener.closeConnection will call' ' connection.close even if the connection is marked stale', () async { - OutboundConnection oc = OutboundConnectionImpl(createMockAtServerSocket('test.test.test', 12345)); + OutboundConnection oc = OutboundConnectionImpl( + createMockAtServerSocket('test.test.test', 12345)); OutboundMessageListener oml = OutboundMessageListener(oc); expect((oc.getSocket() as MockSecureSocket).destroyed, false); expect(oc.metaData?.isClosed, false); diff --git a/packages/at_lookup/test/secondary_address_cache_test.dart b/packages/at_lookup/test/secondary_address_cache_test.dart index 807b4f19..326220f3 100644 --- a/packages/at_lookup/test/secondary_address_cache_test.dart +++ b/packages/at_lookup/test/secondary_address_cache_test.dart @@ -58,7 +58,8 @@ void main() async { }); test('test lookup of @alice on non-existent atDirectory', () async { - CacheableSecondaryAddressFinder cache = CacheableSecondaryAddressFinder('root.no.no.no', 64); + CacheableSecondaryAddressFinder cache = + CacheableSecondaryAddressFinder('root.no.no.no', 64); expect(() async => await cache.findSecondary('@alice'), throwsA(predicate((e) => e is RootServerConnectivityException))); }); @@ -128,7 +129,9 @@ void main() async { // }); }); - group('some cache tests with a real SecondaryUrlFinder on a mocked root server', () { + group( + 'some cache tests with a real SecondaryUrlFinder on a mocked root server', + () { registerFallbackValue(SecureSocketConfig()); String atSign = '@alice'; String noAtAtSign = atSign.replaceFirst('@', ''); @@ -163,14 +166,15 @@ void main() async { cachingAtServerFinder = CacheableSecondaryAddressFinder( mockAtDirectoryHost, 64, - secondaryFinder: - SecondaryUrlFinder(mockAtDirectoryHost, 64, socketFactory: mockSocketFactory)); + secondaryFinder: SecondaryUrlFinder(mockAtDirectoryHost, 64, + socketFactory: mockSocketFactory)); numSocketCreateCalls = 0; when(() => - mockSocketFactory.createSocket(mockAtDirectoryHost, '64', any())) + mockSocketFactory.createSocket(mockAtDirectoryHost, '64', any())) .thenAnswer((invocation) { - print ('mock create socket: numFailures $numSocketCreateCalls requiredFailures $requiredFailures'); + print( + 'mock create socket: numFailures $numSocketCreateCalls requiredFailures $requiredFailures'); if (numSocketCreateCalls++ < requiredFailures) { throw SocketException('Simulating socket connection failure'); } else { @@ -191,44 +195,48 @@ void main() async { when(() => mockSocket.write('$noAtAtSign\n')) .thenAnswer((Invocation invocation) async { - socketOnDataFn("@$mockedAtServerAddress\n" - .codeUnits); + socketOnDataFn("@$mockedAtServerAddress\n".codeUnits); }); }); - test('test lookup of @alice with mocked atDirectory and zero failures', () async { + test('test lookup of @alice with mocked atDirectory and zero failures', + () async { requiredFailures = 0; SecondaryAddress sa = await cachingAtServerFinder.findSecondary(atSign); expect(sa.toString(), mockedAtServerAddress); - expect(numSocketCreateCalls-1, requiredFailures); + expect(numSocketCreateCalls - 1, requiredFailures); }); - test('test lookup of @alice with mocked atDirectory and 1 failure', () async { + test('test lookup of @alice with mocked atDirectory and 1 failure', + () async { requiredFailures = 1; SecondaryAddress sa = await cachingAtServerFinder.findSecondary(atSign); expect(sa.toString(), mockedAtServerAddress); - expect(numSocketCreateCalls-1, requiredFailures); + expect(numSocketCreateCalls - 1, requiredFailures); }); - test('test lookup of @alice with mocked atDirectory and 2 failures', () async { + test('test lookup of @alice with mocked atDirectory and 2 failures', + () async { requiredFailures = 2; SecondaryAddress sa = await cachingAtServerFinder.findSecondary(atSign); expect(sa.toString(), mockedAtServerAddress); - expect(numSocketCreateCalls-1, requiredFailures); + expect(numSocketCreateCalls - 1, requiredFailures); }); - test('test lookup of @alice with mocked atDirectory and 3 failures', () async { + test('test lookup of @alice with mocked atDirectory and 3 failures', + () async { requiredFailures = 3; SecondaryAddress sa = await cachingAtServerFinder.findSecondary(atSign); expect(sa.toString(), mockedAtServerAddress); - expect(numSocketCreateCalls-1, requiredFailures); + expect(numSocketCreateCalls - 1, requiredFailures); }); - test('test lookup of @alice with mocked atDirectory and 4 failures', () async { + test('test lookup of @alice with mocked atDirectory and 4 failures', + () async { requiredFailures = 4; SecondaryAddress sa = await cachingAtServerFinder.findSecondary(atSign); expect(sa.toString(), mockedAtServerAddress); - expect(numSocketCreateCalls-1, requiredFailures); + expect(numSocketCreateCalls - 1, requiredFailures); }); test('test lookup of @alice with mocked atDirectory and 5 failures',