'use strict';

var S6PEV2YJ_cjs = require('./S6PEV2YJ.cjs');
var KHVGLVR5_cjs = require('./KHVGLVR5.cjs');
var child_process = require('child_process');
var util = require('util');

// src/test.ts
KHVGLVR5_cjs.init_cjs_shims();
var COMMAND_TIMEOUT = 5 * 6e4;
var PULL_TIMEOUT = 10 * 6e4;
var VERSION_TEST_TIMEOUT = 15 * 6e4;
var runCommand = /* @__PURE__ */ KHVGLVR5_cjs.__name(async (command, args, timeout = COMMAND_TIMEOUT) => (await util.promisify(child_process.execFile)(command, args, {
  timeout,
  killSignal: "SIGKILL"
})).stdout.trim(), "runCommand");
var ensureDockerImageExists = /* @__PURE__ */ KHVGLVR5_cjs.__name(async (imageUri) => {
  await runCommand("docker", [
    "run",
    "--rm",
    "--entrypoint",
    "true",
    imageUri
  ], PULL_TIMEOUT);
}, "ensureDockerImageExists");
var testTools = /* @__PURE__ */ KHVGLVR5_cjs.__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,
          S6PEV2YJ_cjs.getImageTag(image)
        ].join(":")).toBe(name);
      });
    }
  });
  describe("Tool versions", () => {
    for (const literalImage of Object.values(images)) {
      const image = literalImage;
      describe(S6PEV2YJ_cjs.getImageTag(image), () => {
        let imageUri;
        beforeAll(async () => {
          imageUri = await S6PEV2YJ_cjs.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");

exports.testTools = testTools;
//# sourceMappingURL=QLR2UW44.cjs.map
//# sourceMappingURL=QLR2UW44.cjs.map