Compare commits

...

2 Commits

Author SHA1 Message Date
eb4ce6fd68 Bind HTTP server tests to an ephemeral port
Some checks are pending
dependency freshness / dependencies on newest stable (push) Waiting to run
md-naming / markdown naming convention (push) Waiting to run
pre-commit / pre-commit (${{ matrix.group }}) (flutter, flutter-analyze, ) (push) Waiting to run
pre-commit / pre-commit (${{ matrix.group }}) (mypy, mypy, ) (push) Waiting to run
pre-commit / pre-commit (${{ matrix.group }}) (pylint, pylint, ) (push) Waiting to run
pre-commit / pre-commit (${{ matrix.group }}) (rest, , mypy,pylint,flutter-analyze) (push) Waiting to run
Tests / test (push) Waiting to run
Tests / lock-popup-safety (push) Waiting to run
Tests / flutter test (shard ${{ matrix.shard }}) (0) (push) Waiting to run
Tests / flutter test (shard ${{ matrix.shard }}) (1) (push) Waiting to run
Tests / flutter test (shard ${{ matrix.shard }}) (2) (push) Waiting to run
Tests / flutter test (shard ${{ matrix.shard }}) (3) (push) Waiting to run
Tests / flutter test (shard ${{ matrix.shard }}) (4) (push) Waiting to run
Tests / flutter test (shard ${{ matrix.shard }}) (5) (push) Waiting to run
Tests / flutter test (shard ${{ matrix.shard }}) (6) (push) Waiting to run
Tests / flutter test (shard ${{ matrix.shard }}) (7) (push) Waiting to run
Tests / flutter test (shard ${{ matrix.shard }}) (8) (push) Waiting to run
Tests / flutter test (shard ${{ matrix.shard }}) (9) (push) Waiting to run
Tests / flutter-coverage (push) Blocked by required conditions
Tests / web-coverage (push) Waiting to run
release-apk / release (APK) (push) Waiting to run
repo-contract / repo contract (push) Waiting to run
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 11:53:35 +01:00
f0d4f1036c Bump notification, sqflite, user-event pins
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 11:50:20 +01:00
6 changed files with 32 additions and 24 deletions

View File

@ -26,6 +26,14 @@ class HttpServerService {
HttpServer? _server;
/// Port [start] binds. Tests set 0 (ephemeral) so a host process that
/// already owns 8765 cannot make them fail or answer in our place.
@visibleForTesting
int port = kWorkoutServerPort;
/// The port actually bound, or null while stopped.
int? get boundPort => _server?.port;
/// The most recent workout JSON string (updated after each finished workout).
String? _latestJson;
@ -53,16 +61,13 @@ class HttpServerService {
if (_server != null) return; // already running
await _loadFromDisk();
try {
_server = await HttpServer.bind(
InternetAddress.anyIPv4,
kWorkoutServerPort,
);
_server = await HttpServer.bind(InternetAddress.anyIPv4, port);
unawaited(_serve());
} on SocketException catch (error) {
// Port already in use or binding failed — not fatal.
debugPrint(
'WorkoutApp: could not bind the workout HTTP server on port '
'$kWorkoutServerPort ($error) — the PC cannot pull workouts over '
'$port ($error) — the PC cannot pull workouts over '
'HTTP; ADB and sync still work.',
);
_server = null;

View File

@ -420,10 +420,10 @@ packages:
dependency: "direct main"
description:
name: flutter_local_notifications
sha256: e99e9c6078d1359ba131b2c1eb8d68837170836a01bf2cea3cf2fa13e62ac2ac
sha256: "58f9ea245d7194363c05f7a012bbc73291736c2d8b5f555a8e0ea3f9121868b4"
url: "https://pub.dev"
source: hosted
version: "23.0.0"
version: "23.0.1"
flutter_local_notifications_linux:
dependency: transitive
description:
@ -452,10 +452,10 @@ packages:
dependency: transitive
description:
name: flutter_local_notifications_windows
sha256: c2d6efe9ba585d5f560d8b329131f00fe745834848e6221b22d1f62e0f0b16e2
sha256: "8e80ac29433c71e267493b397457e3a8430c5c1d9c76bb58a6971c016cdba3d7"
url: "https://pub.dev"
source: hosted
version: "4.0.0"
version: "4.0.1"
flutter_map:
dependency: "direct main"
description:
@ -1116,10 +1116,10 @@ packages:
dependency: "direct main"
description:
name: sqflite_common_ffi
sha256: "26911d808e4d33b3965da8821440ef4b021d3bc7282f5eb76e6621827995dd86"
sha256: "9aad7a63bb8de6fe4c1e5367e8dcd8dfc89d491f44a526edf8e58a5a1fb1feed"
url: "https://pub.dev"
source: hosted
version: "2.4.6"
version: "2.4.7"
sqflite_darwin:
dependency: transitive
description:

View File

@ -34,7 +34,7 @@ dependencies:
flutter_foreground_task: 11.0.3
# The break-end alert itself, on its own high-importance channel so the OS
# rings even if the Flutter isolate is busy.
flutter_local_notifications: 23.0.0
flutter_local_notifications: 23.0.1
# The run map and its tile disk cache.
flutter_map: 8.3.2
flutter_map_cache: 2.1.2
@ -59,7 +59,7 @@ dependencies:
sqflite: 2.4.6
# Linux desktop has no sqflite plugin; the FFI factory drives the same
# schema (and already backed the test suite before the desktop target).
sqflite_common_ffi: 2.4.6
sqflite_common_ffi: 2.4.7
sync_settings_ui:
git:
url: https://github.com/kuhyx/utils

View File

@ -5,8 +5,11 @@ import 'package:workout_app/services/http_server_service.dart';
void main() {
group('HttpServerService', () {
// Ephemeral port: the host may already run something on 8765.
setUp(() => HttpServerService.instance.port = 0);
tearDown(() async {
await HttpServerService.instance.stop();
HttpServerService.instance.port = kWorkoutServerPort;
});
test('is a singleton', () {
@ -44,22 +47,22 @@ void main() {
});
test('start swallows a bind failure when the port is taken', () async {
final blocker = await ServerSocket.bind(
InternetAddress.anyIPv4,
kWorkoutServerPort,
);
final blocker = await ServerSocket.bind(InternetAddress.anyIPv4, 0);
HttpServerService.instance.port = blocker.port;
// Binding fails (SocketException) but start() must not throw.
await HttpServerService.instance.start();
expect(HttpServerService.instance.boundPort, isNull);
await blocker.close();
});
test('serves the latest workout over HTTP', () async {
HttpServerService.instance.resetForTesting();
await HttpServerService.instance.start();
final port = HttpServerService.instance.boundPort!;
final client = HttpClient();
Future<int> get(String path) async {
final req = await client.get('localhost', kWorkoutServerPort, path);
final req = await client.get('localhost', port, path);
final resp = await req.close();
await resp.drain<void>();
return resp.statusCode;

View File

@ -25,7 +25,7 @@
"@eslint/js": "10.0.1",
"@testing-library/dom": "10.4.2",
"@testing-library/jest-dom": "7.0.1",
"@testing-library/user-event": "14.6.8",
"@testing-library/user-event": "14.6.9",
"@types/node": "26.6.6",
"@vitest/coverage-v8": "5.1.0",
"eslint": "10.14.0",

View File

@ -192,8 +192,8 @@ importers:
specifier: 7.0.1
version: 7.0.1(@testing-library/dom@10.4.2)(vitest@5.1.0)
'@testing-library/user-event':
specifier: 14.6.8
version: 14.6.8(@testing-library/dom@10.4.2)
specifier: 14.6.9
version: 14.6.9(@testing-library/dom@10.4.2)
'@types/node':
specifier: 26.6.6
version: 26.6.6
@ -906,8 +906,8 @@ packages:
vitest:
optional: true
'@testing-library/user-event@14.6.8':
resolution: {integrity: sha512-vgSSqnANMnkcYR/vUNDbwS7aM3OErRLNUG8vCVVlj4oc6cKffUrccX7UAS5AmJQQNZTSibi9z5GvvRZ0aYgUCQ==}
'@testing-library/user-event@14.6.9':
resolution: {integrity: sha512-/8boTjZHNXFi8JGUI2Ev05cq0Szh0OX35Bamkq6CK1ne+l1Xm8BKE3+nGgsnFgaYk0MX67Vh59cZDsNz5lJJEg==}
engines: {node: '>=12', npm: '>=6'}
peerDependencies:
'@testing-library/dom': '>=7.21.4'
@ -3132,7 +3132,7 @@ snapshots:
optionalDependencies:
vitest: 5.1.0(@types/node@26.6.6)(@vitest/coverage-v8@5.1.0)(jsdom@31.0.0)(vite@8.3.7(@types/node@26.6.6)(yaml@2.9.1))
'@testing-library/user-event@14.6.8(@testing-library/dom@10.4.2)':
'@testing-library/user-event@14.6.9(@testing-library/dom@10.4.2)':
dependencies:
'@testing-library/dom': 10.4.2