chore: bump line length to 120 (#20191)

This commit is contained in:
shenlong 2025-07-25 08:07:22 +05:30 committed by GitHub
parent 977c9b96ba
commit ad65e9011a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
517 changed files with 4520 additions and 9514 deletions

View file

@ -58,8 +58,7 @@ void main() {
const testUrl = 'http://ip:2283';
const resolvedUrl = 'http://ip:2283/api';
when(() => apiService.resolveAndSetEndpoint(testUrl))
.thenAnswer((_) async => resolvedUrl);
when(() => apiService.resolveAndSetEndpoint(testUrl)).thenAnswer((_) async => resolvedUrl);
when(() => apiService.setDeviceInfoHeader()).thenAnswer((_) async => {});
final result = await sut.validateServerUrl(testUrl);
@ -74,8 +73,7 @@ void main() {
const testUrl = 'https://immich.domain.com';
const resolvedUrl = 'https://immich.domain.com/api';
when(() => apiService.resolveAndSetEndpoint(testUrl))
.thenAnswer((_) async => resolvedUrl);
when(() => apiService.resolveAndSetEndpoint(testUrl)).thenAnswer((_) async => resolvedUrl);
when(() => apiService.setDeviceInfoHeader()).thenAnswer((_) async => {});
final result = await sut.validateServerUrl(testUrl);
@ -89,8 +87,7 @@ void main() {
test('Should throw error on invalid URL', () async {
const testUrl = 'invalid-url';
when(() => apiService.resolveAndSetEndpoint(testUrl))
.thenThrow(Exception('Invalid URL'));
when(() => apiService.resolveAndSetEndpoint(testUrl)).thenThrow(Exception('Invalid URL'));
expect(
() async => await sut.validateServerUrl(testUrl),
@ -104,8 +101,7 @@ void main() {
test('Should throw error on unreachable server', () async {
const testUrl = 'https://unreachable.server';
when(() => apiService.resolveAndSetEndpoint(testUrl))
.thenThrow(Exception('Server is not reachable'));
when(() => apiService.resolveAndSetEndpoint(testUrl)).thenThrow(Exception('Server is not reachable'));
expect(
() async => await sut.validateServerUrl(testUrl),
@ -121,8 +117,7 @@ void main() {
test('Should logout user', () async {
when(() => authApiRepository.logout()).thenAnswer((_) async => {});
when(() => backgroundSyncManager.cancel()).thenAnswer((_) async => {});
when(() => authRepository.clearLocalData())
.thenAnswer((_) => Future.value(null));
when(() => authRepository.clearLocalData()).thenAnswer((_) => Future.value(null));
await sut.logout();
@ -132,11 +127,9 @@ void main() {
});
test('Should clear local data even on server error', () async {
when(() => authApiRepository.logout())
.thenThrow(Exception('Server error'));
when(() => authApiRepository.logout()).thenThrow(Exception('Server error'));
when(() => backgroundSyncManager.cancel()).thenAnswer((_) async => {});
when(() => authRepository.clearLocalData())
.thenAnswer((_) => Future.value(null));
when(() => authRepository.clearLocalData()).thenAnswer((_) => Future.value(null));
await sut.logout();
@ -148,13 +141,11 @@ void main() {
group('setOpenApiServiceEndpoint', () {
setUp(() {
when(() => networkService.getWifiName())
.thenAnswer((_) async => 'TestWifi');
when(() => networkService.getWifiName()).thenAnswer((_) async => 'TestWifi');
});
test('Should return null if auto endpoint switching is disabled', () async {
when(() => authRepository.getEndpointSwitchingFeature())
.thenReturn((false));
when(() => authRepository.getEndpointSwitchingFeature()).thenReturn((false));
final result = await sut.setOpenApiServiceEndpoint();
@ -166,8 +157,7 @@ void main() {
test('Should set local connection if wifi name matches', () async {
when(() => authRepository.getEndpointSwitchingFeature()).thenReturn(true);
when(() => authRepository.getPreferredWifiName()).thenReturn('TestWifi');
when(() => authRepository.getLocalEndpoint())
.thenReturn('http://local.endpoint');
when(() => authRepository.getLocalEndpoint()).thenReturn('http://local.endpoint');
when(() => apiService.resolveAndSetEndpoint('http://local.endpoint'))
.thenAnswer((_) async => 'http://local.endpoint');
@ -178,14 +168,12 @@ void main() {
verify(() => networkService.getWifiName()).called(1);
verify(() => authRepository.getPreferredWifiName()).called(1);
verify(() => authRepository.getLocalEndpoint()).called(1);
verify(() => apiService.resolveAndSetEndpoint('http://local.endpoint'))
.called(1);
verify(() => apiService.resolveAndSetEndpoint('http://local.endpoint')).called(1);
});
test('Should set external endpoint if wifi name not matching', () async {
when(() => authRepository.getEndpointSwitchingFeature()).thenReturn(true);
when(() => authRepository.getPreferredWifiName())
.thenReturn('DifferentWifi');
when(() => authRepository.getPreferredWifiName()).thenReturn('DifferentWifi');
when(() => authRepository.getExternalEndpointList()).thenReturn([
const AuxilaryEndpoint(
url: 'https://external.endpoint',
@ -208,11 +196,9 @@ void main() {
).called(1);
});
test('Should set second external endpoint if the first throw any error',
() async {
test('Should set second external endpoint if the first throw any error', () async {
when(() => authRepository.getEndpointSwitchingFeature()).thenReturn(true);
when(() => authRepository.getPreferredWifiName())
.thenReturn('DifferentWifi');
when(() => authRepository.getPreferredWifiName()).thenReturn('DifferentWifi');
when(() => authRepository.getExternalEndpointList()).thenReturn([
const AuxilaryEndpoint(
url: 'https://external.endpoint',
@ -243,11 +229,9 @@ void main() {
).called(1);
});
test('Should set second external endpoint if the first throw ApiException',
() async {
test('Should set second external endpoint if the first throw ApiException', () async {
when(() => authRepository.getEndpointSwitchingFeature()).thenReturn(true);
when(() => authRepository.getPreferredWifiName())
.thenReturn('DifferentWifi');
when(() => authRepository.getPreferredWifiName()).thenReturn('DifferentWifi');
when(() => authRepository.getExternalEndpointList()).thenReturn([
const AuxilaryEndpoint(
url: 'https://external.endpoint',
@ -281,8 +265,7 @@ void main() {
test('Should handle error when setting local connection', () async {
when(() => authRepository.getEndpointSwitchingFeature()).thenReturn(true);
when(() => authRepository.getPreferredWifiName()).thenReturn('TestWifi');
when(() => authRepository.getLocalEndpoint())
.thenReturn('http://local.endpoint');
when(() => authRepository.getLocalEndpoint()).thenReturn('http://local.endpoint');
when(() => apiService.resolveAndSetEndpoint('http://local.endpoint'))
.thenThrow(Exception('Local endpoint error'));
@ -293,14 +276,12 @@ void main() {
verify(() => networkService.getWifiName()).called(1);
verify(() => authRepository.getPreferredWifiName()).called(1);
verify(() => authRepository.getLocalEndpoint()).called(1);
verify(() => apiService.resolveAndSetEndpoint('http://local.endpoint'))
.called(1);
verify(() => apiService.resolveAndSetEndpoint('http://local.endpoint')).called(1);
});
test('Should handle error when setting external connection', () async {
when(() => authRepository.getEndpointSwitchingFeature()).thenReturn(true);
when(() => authRepository.getPreferredWifiName())
.thenReturn('DifferentWifi');
when(() => authRepository.getPreferredWifiName()).thenReturn('DifferentWifi');
when(() => authRepository.getExternalEndpointList()).thenReturn([
const AuxilaryEndpoint(
url: 'https://external.endpoint',