-
Notifications
You must be signed in to change notification settings - Fork 130
Expand file tree
/
Copy pathboot-diagnostics.test.ts
More file actions
30 lines (26 loc) · 1.03 KB
/
boot-diagnostics.test.ts
File metadata and controls
30 lines (26 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import test from 'node:test';
import assert from 'node:assert/strict';
import { classifyBootFailure } from '../boot-diagnostics.ts';
import { AppError } from '../../utils/errors.ts';
test('classifyBootFailure maps timeout errors', () => {
const reason = classifyBootFailure({ message: 'bootstatus timed out after 120s' });
assert.equal(reason, 'BOOT_TIMEOUT');
});
test('classifyBootFailure maps adb offline errors', () => {
const reason = classifyBootFailure({ stderr: 'error: device offline' });
assert.equal(reason, 'DEVICE_OFFLINE');
});
test('classifyBootFailure maps tool missing from AppError code', () => {
const reason = classifyBootFailure({
error: new AppError('TOOL_MISSING', 'adb not found in PATH'),
});
assert.equal(reason, 'TOOL_MISSING');
});
test('classifyBootFailure reads stderr from AppError details', () => {
const reason = classifyBootFailure({
error: new AppError('COMMAND_FAILED', 'adb failed', {
stderr: 'error: device unauthorized',
}),
});
assert.equal(reason, 'PERMISSION_DENIED');
});