refactor(updates): pass typed runtime policy to deskup
This commit is contained in:
1 parent
1ef8edc8bc
commit
d83f94afd5
13 files changed
+158
-102
No files matched your search
@@ -5,11 +5,15 @@ import 'dart:io';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:deskup/deskup.dart';
|
||||
|
||||
const channel = MethodChannel('deskup');
|
||||
const smokeRoot = String.fromEnvironment('CUTDEX_UPDATE_SMOKE_ROOT');
|
||||
|
||||
void main() {
|
||||
List<String> restartArguments = [];
|
||||
|
||||
void main(List<String> arguments) {
|
||||
restartArguments = arguments;
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
// The isolated smoke fixture depends only on Flutter, without Riverpod.
|
||||
// ignore: riverpod_lint/missing_provider_scope
|
||||
@@ -48,13 +52,33 @@ Future<void> runSmoke() async {
|
||||
throw StateError('Set CUTDEX_UPDATE_SMOKE_ROOT for this test app');
|
||||
}
|
||||
try {
|
||||
await channel.invokeMethod<void>('ready');
|
||||
final updater = Deskup(
|
||||
windows: WindowsUpdateConfiguration(
|
||||
source: WebUpdateSource(
|
||||
url: Uri.parse(
|
||||
const String.fromEnvironment('CUTDEX_WINDOWS_UPDATE_URL'),
|
||||
),
|
||||
allowLocalHttp: true,
|
||||
),
|
||||
expectedPackageId: 'Cutdex.Dev',
|
||||
preferenceNamespace: 'Cutdex.UpdateSmoke',
|
||||
automaticCheckInterval: const Duration(minutes: 5),
|
||||
maximumDeltas: -1,
|
||||
),
|
||||
);
|
||||
await updater.initialize();
|
||||
final initial = await waitFor(
|
||||
(value) => value['configured'] == true && value['canCheck'] == true,
|
||||
);
|
||||
await channel.invokeMethod<void>('check');
|
||||
var checked = await waitFor((value) => value['canCheck'] == true);
|
||||
if (initial['build'] == '900002') {
|
||||
if (!restartArguments.contains('--deskup-smoke-restart') ||
|
||||
!restartArguments.contains('文档 with spaces')) {
|
||||
throw StateError(
|
||||
'Restart arguments were not preserved: $restartArguments',
|
||||
);
|
||||
}
|
||||
if (checked['phase'] != 'current') {
|
||||
throw StateError('Updated version was offered again: $checked');
|
||||
}
|
||||
@@ -78,7 +102,11 @@ Future<void> runSmoke() async {
|
||||
}
|
||||
await record('before', checked);
|
||||
await channel.invokeMethod<void>('validateInstall');
|
||||
await channel.invokeMethod<void>('install');
|
||||
await updater.install(
|
||||
silent: true,
|
||||
restart: true,
|
||||
restartArguments: ['--deskup-smoke-restart', '文档 with spaces'],
|
||||
);
|
||||
} catch (error, stack) {
|
||||
await record('failure', {'error': '$error', 'stack': '$stack'});
|
||||
exit(1);
|
||||
|
||||
Reference in new issue
Block a user