mirror of
https://github.com/morluto/rea.git
synced 2026-12-03 21:46:01 +00:00
test(capabilities): reuse open executable status fixture (#16025)
This commit is contained in:
1 parent
edb3b9a996
commit
7c53f21da2
1 file changed
+78
-140
@@ -77,17 +77,19 @@ it("adds the retaining close owner's prerequisite without guessing from a pendin
|
||||
expect(unknownOwner?.reason).toBe("target_required");
|
||||
});
|
||||
|
||||
type FixtureCapability = {
|
||||
readonly operation: string;
|
||||
readonly available: boolean;
|
||||
readonly reason: string | null;
|
||||
readonly availability_code?: "unsupported_host";
|
||||
};
|
||||
|
||||
const status = (
|
||||
options: {
|
||||
readonly open?: boolean;
|
||||
readonly kind?: "executable" | "database" | "archive" | "artifact";
|
||||
readonly format?: string;
|
||||
readonly capabilities?: readonly {
|
||||
readonly operation: string;
|
||||
readonly available: boolean;
|
||||
readonly reason: string | null;
|
||||
readonly availability_code?: "unsupported_host";
|
||||
}[];
|
||||
readonly capabilities?: readonly FixtureCapability[];
|
||||
} = {},
|
||||
) => ({
|
||||
open: options.open ?? false,
|
||||
@@ -114,6 +116,9 @@ const status = (
|
||||
],
|
||||
});
|
||||
|
||||
const openExecutableStatus = (capabilities: readonly FixtureCapability[]) =>
|
||||
status({ open: true, kind: "executable", capabilities });
|
||||
|
||||
const entry = (
|
||||
name: string,
|
||||
sessionStatus: ReturnType<typeof status>,
|
||||
@@ -212,17 +217,13 @@ it("derives closed-session address and explicit-path APK availability from their
|
||||
expect(
|
||||
entry(
|
||||
"inspect_address_context",
|
||||
status({
|
||||
open: true,
|
||||
kind: "executable",
|
||||
capabilities: [
|
||||
{
|
||||
operation: "inspect_address_context",
|
||||
available: true,
|
||||
reason: null,
|
||||
},
|
||||
],
|
||||
}),
|
||||
openExecutableStatus([
|
||||
{
|
||||
operation: "inspect_address_context",
|
||||
available: true,
|
||||
reason: null,
|
||||
},
|
||||
]),
|
||||
),
|
||||
).toMatchObject({ available: true, reason: "available" });
|
||||
expect(entry("inspect_apk_signature", status({ open: true }))).toMatchObject({
|
||||
@@ -357,52 +358,40 @@ describe("capability failure reasons", () => {
|
||||
{
|
||||
label: "distinguishes an unsupported host",
|
||||
name: "current_address",
|
||||
sessionStatus: status({
|
||||
open: true,
|
||||
kind: "executable",
|
||||
capabilities: [
|
||||
{
|
||||
operation: "current_address",
|
||||
available: false,
|
||||
availability_code: "unsupported_host",
|
||||
reason: "Operation requires macOS",
|
||||
},
|
||||
],
|
||||
}),
|
||||
sessionStatus: openExecutableStatus([
|
||||
{
|
||||
operation: "current_address",
|
||||
available: false,
|
||||
availability_code: "unsupported_host",
|
||||
reason: "Operation requires macOS",
|
||||
},
|
||||
]),
|
||||
reason: "unsupported_host",
|
||||
remediation: "macOS",
|
||||
},
|
||||
{
|
||||
label: "retains a provider failure",
|
||||
name: "current_address",
|
||||
sessionStatus: status({
|
||||
open: true,
|
||||
kind: "executable",
|
||||
capabilities: [
|
||||
{
|
||||
operation: "current_address",
|
||||
available: false,
|
||||
reason: "Provider session is unhealthy",
|
||||
},
|
||||
],
|
||||
}),
|
||||
sessionStatus: openExecutableStatus([
|
||||
{
|
||||
operation: "current_address",
|
||||
available: false,
|
||||
reason: "Provider session is unhealthy",
|
||||
},
|
||||
]),
|
||||
reason: "provider_unavailable",
|
||||
remediation: "unhealthy",
|
||||
},
|
||||
{
|
||||
label: "reports an available provider operation",
|
||||
name: "current_address",
|
||||
sessionStatus: status({
|
||||
open: true,
|
||||
kind: "executable",
|
||||
capabilities: [
|
||||
{
|
||||
operation: "current_address",
|
||||
available: true,
|
||||
reason: null,
|
||||
},
|
||||
],
|
||||
}),
|
||||
sessionStatus: openExecutableStatus([
|
||||
{
|
||||
operation: "current_address",
|
||||
available: true,
|
||||
reason: null,
|
||||
},
|
||||
]),
|
||||
reason: "available",
|
||||
remediation: null,
|
||||
},
|
||||
@@ -616,10 +605,7 @@ describe("partial navigation availability", () => {
|
||||
reason: null,
|
||||
}));
|
||||
expect(
|
||||
entry(
|
||||
"get_navigation_context",
|
||||
status({ open: true, kind: "executable", capabilities }),
|
||||
),
|
||||
entry("get_navigation_context", openExecutableStatus(capabilities)),
|
||||
).toMatchObject({
|
||||
available: true,
|
||||
reason: "available",
|
||||
@@ -632,11 +618,7 @@ describe("partial navigation availability", () => {
|
||||
expect(
|
||||
entry(
|
||||
"get_navigation_context",
|
||||
status({
|
||||
open: true,
|
||||
kind: "executable",
|
||||
capabilities: capabilities.slice(1),
|
||||
}),
|
||||
openExecutableStatus(capabilities.slice(1)),
|
||||
),
|
||||
).toMatchObject({
|
||||
available: true,
|
||||
@@ -650,11 +632,7 @@ describe("partial navigation availability", () => {
|
||||
expect(
|
||||
entry(
|
||||
"get_navigation_context",
|
||||
status({
|
||||
open: true,
|
||||
kind: "executable",
|
||||
capabilities: capabilities.slice(1, 2),
|
||||
}),
|
||||
openExecutableStatus(capabilities.slice(1, 2)),
|
||||
),
|
||||
).toMatchObject({
|
||||
available: false,
|
||||
@@ -667,23 +645,19 @@ describe("partial navigation availability", () => {
|
||||
expect(
|
||||
entry(
|
||||
"get_navigation_context",
|
||||
status({
|
||||
open: true,
|
||||
kind: "executable",
|
||||
capabilities: [
|
||||
{
|
||||
operation: "current_address",
|
||||
available: false,
|
||||
availability_code: "unsupported_host",
|
||||
reason: "Navigation requires macOS.",
|
||||
},
|
||||
{
|
||||
operation: "resolve_containing_procedure",
|
||||
available: true,
|
||||
reason: null,
|
||||
},
|
||||
],
|
||||
}),
|
||||
openExecutableStatus([
|
||||
{
|
||||
operation: "current_address",
|
||||
available: false,
|
||||
availability_code: "unsupported_host",
|
||||
reason: "Navigation requires macOS.",
|
||||
},
|
||||
{
|
||||
operation: "resolve_containing_procedure",
|
||||
available: true,
|
||||
reason: null,
|
||||
},
|
||||
]),
|
||||
),
|
||||
).toMatchObject({
|
||||
available: false,
|
||||
@@ -764,17 +738,13 @@ describe("binary_overview capability requirements", () => {
|
||||
expect(
|
||||
entry(
|
||||
"binary_overview",
|
||||
status({
|
||||
open: true,
|
||||
kind: "executable",
|
||||
capabilities: [
|
||||
{
|
||||
operation: "read_binary_inventory_summary",
|
||||
available: true,
|
||||
reason: null,
|
||||
},
|
||||
],
|
||||
}),
|
||||
openExecutableStatus([
|
||||
{
|
||||
operation: "read_binary_inventory_summary",
|
||||
available: true,
|
||||
reason: null,
|
||||
},
|
||||
]),
|
||||
),
|
||||
).toMatchObject({ available: true, reason: "available" });
|
||||
});
|
||||
@@ -785,10 +755,7 @@ describe("binary_overview capability requirements", () => {
|
||||
"list_strings",
|
||||
].map((operation) => ({ operation, available: true, reason: null }));
|
||||
expect(
|
||||
entry(
|
||||
"binary_overview",
|
||||
status({ open: true, kind: "executable", capabilities }),
|
||||
),
|
||||
entry("binary_overview", openExecutableStatus(capabilities)),
|
||||
).toMatchObject({
|
||||
available: true,
|
||||
reason: "available",
|
||||
@@ -803,10 +770,7 @@ describe("binary_overview capability requirements", () => {
|
||||
"list_strings",
|
||||
].map((operation) => ({ operation, available: true, reason: null }));
|
||||
expect(
|
||||
entry(
|
||||
"binary_overview",
|
||||
status({ open: true, kind: "executable", capabilities }),
|
||||
),
|
||||
entry("binary_overview", openExecutableStatus(capabilities)),
|
||||
).toMatchObject({
|
||||
available: true,
|
||||
reason: "available",
|
||||
@@ -821,10 +785,7 @@ describe("binary_overview capability requirements", () => {
|
||||
"list_strings",
|
||||
].map((operation) => ({ operation, available: true, reason: null }));
|
||||
expect(
|
||||
entry(
|
||||
"binary_overview",
|
||||
status({ open: true, kind: "executable", capabilities }),
|
||||
),
|
||||
entry("binary_overview", openExecutableStatus(capabilities)),
|
||||
).toMatchObject({
|
||||
available: false,
|
||||
reason: "provider_missing",
|
||||
@@ -846,10 +807,7 @@ describe("binary_overview capability requirements", () => {
|
||||
{ operation: "list_strings", available: true, reason: null },
|
||||
];
|
||||
expect(
|
||||
entry(
|
||||
"binary_overview",
|
||||
status({ open: true, kind: "executable", capabilities }),
|
||||
),
|
||||
entry("binary_overview", openExecutableStatus(capabilities)),
|
||||
).toMatchObject({ available: true, reason: "available" });
|
||||
});
|
||||
|
||||
@@ -865,10 +823,7 @@ describe("binary_overview capability requirements", () => {
|
||||
{ operation: "list_strings", available: true, reason: null },
|
||||
];
|
||||
expect(
|
||||
entry(
|
||||
"binary_overview",
|
||||
status({ open: true, kind: "executable", capabilities }),
|
||||
),
|
||||
entry("binary_overview", openExecutableStatus(capabilities)),
|
||||
).toMatchObject({
|
||||
available: false,
|
||||
reason: "provider_unavailable",
|
||||
@@ -889,15 +844,9 @@ describe("trace_feature requirements", () => {
|
||||
expect(
|
||||
entry(
|
||||
"trace_feature",
|
||||
status({
|
||||
open: true,
|
||||
kind: "executable",
|
||||
capabilities: capabilities([
|
||||
"search_strings",
|
||||
"search_procedures",
|
||||
"xrefs",
|
||||
]),
|
||||
}),
|
||||
openExecutableStatus(
|
||||
capabilities(["search_strings", "search_procedures", "xrefs"]),
|
||||
),
|
||||
),
|
||||
).toMatchObject({ available: true, reason: "available" });
|
||||
});
|
||||
@@ -906,16 +855,14 @@ describe("trace_feature requirements", () => {
|
||||
expect(
|
||||
entry(
|
||||
"trace_feature",
|
||||
status({
|
||||
open: true,
|
||||
kind: "executable",
|
||||
capabilities: capabilities([
|
||||
openExecutableStatus(
|
||||
capabilities([
|
||||
"search_strings",
|
||||
"search_procedures",
|
||||
"xrefs",
|
||||
"resolve_containing_procedure",
|
||||
]),
|
||||
}),
|
||||
),
|
||||
),
|
||||
).toMatchObject({ available: true, reason: "available" });
|
||||
});
|
||||
@@ -931,14 +878,7 @@ describe("trace_feature requirements", () => {
|
||||
].filter((operation) => operation !== missing);
|
||||
|
||||
expect(
|
||||
entry(
|
||||
"trace_feature",
|
||||
status({
|
||||
open: true,
|
||||
kind: "executable",
|
||||
capabilities: capabilities(operations),
|
||||
}),
|
||||
),
|
||||
entry("trace_feature", openExecutableStatus(capabilities(operations))),
|
||||
).toMatchObject({ available: false, reason: "provider_missing" });
|
||||
},
|
||||
);
|
||||
@@ -947,16 +887,14 @@ describe("trace_feature requirements", () => {
|
||||
expect(
|
||||
entry(
|
||||
"trace_feature",
|
||||
status({
|
||||
open: true,
|
||||
kind: "executable",
|
||||
capabilities: capabilities([
|
||||
openExecutableStatus(
|
||||
capabilities([
|
||||
"list_strings",
|
||||
"list_procedures",
|
||||
"xrefs",
|
||||
"resolve_containing_procedure",
|
||||
]),
|
||||
}),
|
||||
),
|
||||
),
|
||||
).toMatchObject({ available: false, reason: "provider_missing" });
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user