import { getImageTag, getImageUri } from './AXL4SBDJ.js';
import { init_esm_shims, __name } from './CWKWODSW.js';
import { execFile } from 'child_process';
import { promisify } from 'util';

// src/test.ts
init_esm_shims();
var COMMAND_TIMEOUT = 5 * 6e4;
var PULL_TIMEOUT = 10 * 6e4;
var VERSION_TEST_TIMEOUT = 15 * 6e4;
var runCommand = /* @__PURE__ */ __name(async (command, args, timeout = COMMAND_TIMEOUT) => (await promisify(execFile)(command, args, {
  timeout,
  killSignal: "SIGKILL"
})).stdout.trim(), "runCommand");
var ensureDockerImageExists = /* @__PURE__ */ __name(async (imageUri) => {
  await runCommand("docker", [
    "run",
    "--rm",
    "--entrypoint",
    "true",
    imageUri
  ], PULL_TIMEOUT);
}, "ensureDockerImageExists");
var testTools = /* @__PURE__ */ __name(({ describe, expect, it, beforeAll }, images, _versionCombinations, versionCommands) => {
  describe("Docker image IDs", () => {
    for (const [name, image] of Object.entries(images)) {
      it(`has an image ID of ${name}`, () => {
        expect([
          image.name,
          getImageTag(image)
        ].join(":")).toBe(name);
      });
    }
  });
  describe("Tool versions", () => {
    for (const literalImage of Object.values(images)) {
      const image = literalImage;
      describe(getImageTag(image), () => {
        let imageUri;
        beforeAll(async () => {
          imageUri = await getImageUri(image);
          await ensureDockerImageExists(imageUri);
        }, PULL_TIMEOUT);
        for (const [tool, expectedVersion] of Object.entries(image.versions)) {
          it(`should have ${tool} of version ${expectedVersion}`, async () => {
            if (!(versionCommands[tool] instanceof Array)) {
              throw new Error("Missing version command");
            }
            const version = await runCommand("docker", [
              "run",
              "--rm",
              "--privileged",
              imageUri,
              ...versionCommands[tool]
            ]);
            expect(version).toContain(expectedVersion);
          }, VERSION_TEST_TIMEOUT);
        }
      });
    }
  });
}, "testTools");

export { testTools };
//# sourceMappingURL=BTPRTHPR.js.map
//# sourceMappingURL=BTPRTHPR.js.map