MCPcopy Create free account
hub / github.com/EvilFreelancer/openapi-to-cli / createTwoProfileDeps

Function createTwoProfileDeps

tests/cli.test.ts:1443–1501  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1441
1442 describe("--profile/-p flag", () => {
1443 function createTwoProfileDeps() {
1444 const localDir = `${cwd}/.ocli`;
1445 const profilesPath = `${localDir}/profiles.ini`;
1446 const cacheA = `${localDir}/specs/api-a.json`;
1447 const cacheB = `${localDir}/specs/api-b.json`;
1448
1449 const specA = {
1450 openapi: "3.0.0",
1451 paths: {
1452 "/ping": { get: { summary: "Ping A" } },
1453 },
1454 };
1455 const specB = {
1456 openapi: "3.0.0",
1457 paths: {
1458 "/ping": { get: { summary: "Ping B" } },
1459 "/only-b": { get: { summary: "Only available on B" } },
1460 },
1461 };
1462
1463 const iniContent = [
1464 "[api-a]",
1465 "api_base_url = https://a.example.com",
1466 "api_basic_auth = ",
1467 "api_bearer_token = ",
1468 "openapi_spec_source = /spec-a.json",
1469 `openapi_spec_cache = ${cacheA}`,
1470 "include_endpoints = ",
1471 "exclude_endpoints = ",
1472 "",
1473 "[api-b]",
1474 "api_base_url = https://b.example.com",
1475 "api_basic_auth = ",
1476 "api_bearer_token = ",
1477 "openapi_spec_source = /spec-b.json",
1478 `openapi_spec_cache = ${cacheB}`,
1479 "include_endpoints = ",
1480 "exclude_endpoints = ",
1481 "",
1482 ].join("\n");
1483
1484 const capturedConfigs: unknown[] = [];
1485 const fakeHttpClient: HttpClient = {
1486 // eslint-disable-next-line @typescript-eslint/no-explicit-any
1487 request: async (config: any) => {
1488 capturedConfigs.push(config);
1489 return { status: 200, statusText: "OK", headers: {}, config, data: { ok: true } };
1490 },
1491 };
1492
1493 const { profileStore, openapiLoader } = createCliDeps(cwd, homeDir, {
1494 [profilesPath]: iniContent,
1495 [cacheA]: JSON.stringify(specA),
1496 [cacheB]: JSON.stringify(specB),
1497 [`${localDir}/current`]: "api-a",
1498 });
1499
1500 return { profileStore, openapiLoader, fakeHttpClient, capturedConfigs };

Callers 1

cli.test.tsFile · 0.85

Calls 1

createCliDepsFunction · 0.85

Tested by

no test coverage detected