import path from "node:path";
import { describe, it } from "node:test";
import { fileURLToPath } from "node:url";
import { expect } from "chai";
import ignore from "ignore";
import { createIgnoreFunction, generateMetadata } from "../deploy/archive.js";
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const basicTestsPath = path.join(__dirname, "..", "..", "..", "..", "test-fixtures", "basic");
describe("Archive utils", async function () {
    it("should not ignore .zuplo using gitignore", function () {
        const ignores = createIgnoreFunction(basicTestsPath);
        const expectedRules = ignore().add(".git/");
        expectedRules.add(".cache/");
        expectedRules.add("dist/");
        expectedRules.add("node_modules/");
        expectedRules.add(".env");
        expectedRules.add(".DS_Store");
        expect(ignores._rules).to.deep.equal(expectedRules._rules);
    });
    it("should return default metadata values", async function () {
        const results = await generateMetadata({
            account: "zuplo-test",
            project: "basic",
            dir: basicTestsPath,
            environment: "basic-1234",
            authToken: "",
        });
        expect(results).to.not.be.empty;
        expect(results.branch).to.equal("basic-1234");
        expect(results.repoUrl).to.not.be.null;
        expect(results.sha).to.not.be.null;
    });
    it("should allow metadata value override on repo url", async function () {
        const results = await generateMetadata({
            account: "zuplo-test",
            project: "basic",
            dir: basicTestsPath,
            environment: "basic-1234",
            authToken: "",
            "override-repo-url": "https://github.com/zuplo/test-override",
        });
        expect(results).to.not.be.empty;
        expect(results.branch).to.equal("basic-1234");
        expect(results.repoUrl).to.not.be.null;
        expect(results.repoUrl).to.equal("https://github.com/zuplo/test-override");
        expect(results.sha).to.not.be.null;
    });
});
//# sourceMappingURL=archive-utils.test.js.map