Say why an app update check found nothing
The check dropped every per-server failure and showed one generic message. It now lists each machine with its reason (sign in first, a feed key this app does not trust, a timeout), and an APK signed with another certificate than the installed app is named plainly with how to install it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/core/servers/server_catalog.dart';
|
||||
import 'package:pipelines_app/features/updates/app_updates.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
void main() {
|
||||
test('a failed check names each machine and why it offered nothing', () async {
|
||||
SharedPreferences.setMockInitialValues({});
|
||||
final tank = SavedServer.validated(
|
||||
id: 'tank',
|
||||
name: 'tank',
|
||||
endpoints: ['wss://tank.test/connect'],
|
||||
);
|
||||
final mac = SavedServer.validated(
|
||||
id: 'mac',
|
||||
name: 'Mac',
|
||||
endpoints: ['wss://mac.test/connect'],
|
||||
);
|
||||
await expectLater(
|
||||
newestServerUpdate(
|
||||
[tank, mac],
|
||||
read: (base, _) async => base.host == 'tank.test'
|
||||
? throw const FormatException(
|
||||
'The update feed is signed by a key this app does not trust.',
|
||||
)
|
||||
: throw TimeoutException('slow'),
|
||||
),
|
||||
throwsA(
|
||||
isA<FormatException>().having(
|
||||
(e) => e.message,
|
||||
'message',
|
||||
allOf(
|
||||
contains(
|
||||
'tank: The update feed is signed by a key this app does not trust.',
|
||||
),
|
||||
contains('Mac: the server did not answer in time'),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
test('an HTTP failure keeps its own words without the exception noise', () {
|
||||
expect(
|
||||
updateProblem(_FakeHttpException('Sign in first (Settings → Sign in).')),
|
||||
'Sign in first (Settings → Sign in).',
|
||||
);
|
||||
});
|
||||
|
||||
test('another Android signing certificate is said plainly', () {
|
||||
final body = jsonEncode({
|
||||
'versionCode': 2,
|
||||
'apk': 'pipelines.apk',
|
||||
'signingCertificateSha256': 'a' * 64,
|
||||
});
|
||||
expect(
|
||||
incompatibleUpdateReason(
|
||||
body,
|
||||
platform: 'android',
|
||||
installedSignature: 'B' * 64,
|
||||
),
|
||||
contains('different certificate'),
|
||||
);
|
||||
expect(
|
||||
incompatibleUpdateReason(
|
||||
body,
|
||||
platform: 'android',
|
||||
installedSignature: 'A' * 64,
|
||||
),
|
||||
'no compatible build is offered for this device',
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
class _FakeHttpException implements Exception {
|
||||
_FakeHttpException(this.message);
|
||||
final String message;
|
||||
@override
|
||||
String toString() => 'HttpException: $message, uri = https://tank.test/x';
|
||||
}
|
||||
Reference in New Issue
Block a user