Files
clide/test/ipc/paths_test.dart
T
jpmschweitzerandClaude Opus 4.8 6d0ebab721 chore: adopt Dart 3.9 toolchain — honest floor + tall-style reformat (T-353)
Raise the declared minimums in pubspec.yaml to what our deps already
require: Flutter >=3.35.0 / Dart >=3.9.0 (was 3.19.0 / 3.5.0). alchemist
0.12 needs Flutter 3.32; Dart 3.9 first ships in Flutter 3.35, so 3.35 is
the binding floor. Pin the exact build toolchain in .fvmrc (Flutter
3.44.1).

Moving to the Dart 3.9 language level switches `dart format` to the new
"tall" style and enables two new lints. This commit is the resulting
mechanical churn, isolated from any behaviour change:
  - whole-tree `dart format` reformat (tall style)
  - `dart fix` for unnecessary_underscores + use_null_aware_elements

No runtime behaviour change; `make test` green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-11 12:11:53 +02:00

66 lines
2.3 KiB
Dart

import 'dart:io';
import 'package:clide/src/ipc/paths.dart';
import 'package:test/test.dart';
void main() {
group('workspaceSocketPath (D-70)', () {
test('returns the FNV-1a hashed path under the socket directory', () {
final p = workspaceSocketPath('/home/me/projects/clide');
expect(p, startsWith('${socketDirectory()}/'));
expect(p, endsWith('.sock'));
// 16-char hex hash.
final hash = p.split('/').last.replaceAll('.sock', '');
expect(hash, matches(RegExp(r'^[0-9a-f]{16}$')));
});
test('is deterministic for the same input', () {
expect(workspaceSocketPath('/home/me/repo'), workspaceSocketPath('/home/me/repo'));
});
test('different workspace roots hash to different paths', () {
expect(workspaceSocketPath('/home/me/repo-a'), isNot(workspaceSocketPath('/home/me/repo-b')));
});
test('socketDirectory uses XDG_RUNTIME_DIR on Linux when set', () {
if (Platform.isMacOS) return;
final xdg = Platform.environment['XDG_RUNTIME_DIR'];
if (xdg != null && xdg.isNotEmpty) {
expect(socketDirectory(), '$xdg/clide');
} else {
expect(socketDirectory(), '/tmp/clide');
}
});
test('socketDirectory uses ~/Library/Caches on macOS', () {
if (!Platform.isMacOS) return;
final home = Platform.environment['HOME']!;
expect(socketDirectory(), '$home/Library/Caches/clide');
});
});
group('fnv1a64Hex (T-126 cross-check)', () {
// Reference values from <http://isthe.com/chongo/tech/comp/fnv/>.
// The C client in native/clide-cli/clide.c MUST produce the same
// 16-char hex strings for the same inputs, or server + client see
// different socket paths and the integration falls apart silently.
test('empty string → offset basis', () {
expect(fnv1a64Hex(''), 'cbf29ce484222325');
});
test('"a" → reference value', () {
expect(fnv1a64Hex('a'), 'af63dc4c8601ec8c');
});
test('"foo" → reference value', () {
expect(fnv1a64Hex('foo'), 'dcb27518fed9d577');
});
test('"/home/me/projects/clide" → 16 hex chars, deterministic', () {
final h = fnv1a64Hex('/home/me/projects/clide');
expect(h, matches(RegExp(r'^[0-9a-f]{16}$')));
expect(fnv1a64Hex('/home/me/projects/clide'), h);
});
});
}