Applying an update downloads and swaps a binary and takes minutes; the doctor showed a spinner inside a disabled button for the whole time. SystemActions gained a streaming CLI runner that hands each line to the caller as it arrives, with CHAIN_PLAIN=1 set for the child so the CLI emits one line per transition instead of its redraw-in-place block. The update card now shows an indeterminate bar labelled with the running step and an elapsed counter on its own timer, so the counter keeps moving between lines that can be minutes apart. No invented percentage: the CLI reports steps, not a measurable total. The streaming path still defers to debugRunFaiOverride, so tests stay hermetic and never spawn a process; three guards pin that. Signed-off-by: flemming-it <stefan.a.flemming@googlemail.com>
55 lines
1.8 KiB
Dart
55 lines
1.8 KiB
Dart
// Guards for the streamed `chain update apply` path.
|
|
//
|
|
// Applying an update downloads and swaps a binary and takes minutes.
|
|
// The bug class: a caller that passes a line callback and silently
|
|
// gets nothing back, or a streaming path that stops honouring the
|
|
// test override and starts spawning real processes in the suite.
|
|
|
|
import 'package:chain_studio/data/system_actions.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
void main() {
|
|
tearDown(() => SystemActions.debugRunFaiOverride = null);
|
|
|
|
test('the test override still wins over the streaming path', () async {
|
|
// Hermetic by construction: with an override installed, no process
|
|
// may be started even when a line callback is supplied.
|
|
var seenArgs = <String>[];
|
|
SystemActions.debugRunFaiOverride = (args) async {
|
|
seenArgs = args;
|
|
return (ok: true, stdout: 'done', stderr: '');
|
|
};
|
|
|
|
var lines = <String>[];
|
|
final r = await SystemActions.chainUpdateApply(
|
|
'stable',
|
|
onLine: lines.add,
|
|
);
|
|
|
|
expect(r.ok, isTrue);
|
|
expect(r.stdout, 'done');
|
|
expect(seenArgs, ['update', 'apply', '--channel', 'stable']);
|
|
expect(lines, isEmpty, reason: 'the override produces no live lines');
|
|
});
|
|
|
|
test('the channel reaches the CLI unchanged', () async {
|
|
var seenArgs = <String>[];
|
|
SystemActions.debugRunFaiOverride = (args) async {
|
|
seenArgs = args;
|
|
return (ok: true, stdout: '', stderr: '');
|
|
};
|
|
|
|
await SystemActions.chainUpdateApply('beta', onLine: (_) {});
|
|
expect(seenArgs, contains('beta'));
|
|
});
|
|
|
|
test('callers without a line callback keep the buffered behaviour',
|
|
() async {
|
|
SystemActions.debugRunFaiOverride =
|
|
(args) async => (ok: false, stdout: '', stderr: 'boom');
|
|
|
|
final r = await SystemActions.chainUpdateApply('stable');
|
|
expect(r.ok, isFalse);
|
|
expect(r.stderr, 'boom');
|
|
});
|
|
}
|