Files
reverse-engineering-anything/src/adb/AdbConfiguration.test.ts
T
morlutoandTaksh e5deb832cb fix(android): report validated ADB and Apktool host availability
Probe the selected clients through their owning providers and expose current host availability through binary_session. Keep device/serial and target applicability separate. Reject unrecognized successful version output; retain the bounded producer output and original version spelling. Apply the documented Apktool floor, including the verified Debian dirty build.

Validation: provider/version tests and public MCP grouped availability; no real Android device or APK provider verification claimed.

Fixes #3067
Fixes #3068
Related: #3077

Co-authored-by: Taksh <takshkothari09@gmail.com>
2026-10-14 16:54:08 +08:00

67 lines
1.8 KiB
TypeScript

import { describe, expect, it } from "vitest";
import {
ADB_BINARY_ENV,
parseAdbVersionOutput,
resolveAdbBinary,
} from "./AdbConfiguration.js";
describe("resolveAdbBinary", () => {
it("prefers an absolute REA_ADB_PATH", () => {
expect(resolveAdbBinary({ [ADB_BINARY_ENV]: "/opt/tools/adb" })).toEqual({
binary: "/opt/tools/adb",
pathSource: "environment",
});
});
it("falls back to PATH resolution without the environment key", () => {
expect(resolveAdbBinary({})).toEqual({
binary: "adb",
pathSource: "path",
});
expect(resolveAdbBinary({ [ADB_BINARY_ENV]: " " })).toEqual({
binary: "adb",
pathSource: "path",
});
});
it("rejects a relative environment path explicitly", () => {
expect(() => resolveAdbBinary({ [ADB_BINARY_ENV]: "tools/adb" })).toThrow(
/must be an absolute path/u,
);
});
});
describe("parseAdbVersionOutput", () => {
it("reads the build version and install path from real output", () => {
expect(
parseAdbVersionOutput(
[
"Android Debug Bridge version 1.0.41",
"Version 34.0.5-debian",
"Installed as /usr/lib/android-sdk/platform-tools/adb",
"",
].join("\n"),
),
).toEqual({
version: "34.0.5-debian",
installedPath: "/usr/lib/android-sdk/platform-tools/adb",
});
});
it("reports null identity fields when the named lines are absent", () => {
expect(parseAdbVersionOutput("unexpected output")).toEqual({
version: null,
installedPath: null,
});
});
it("does not accept arbitrary successful output as an adb version", () => {
expect(
parseAdbVersionOutput(
"Android Debug Bridge version tomorrow\nVersion unknown\n",
),
).toMatchObject({ version: null });
});
});