Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions packages/cdktn/test/canonical-asset-hash.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,41 @@ describe("TerraformAsset artifact layout derives from the packaging", () => {
});
});

describe("TerraformAsset stages inside the stack's own directory (#380)", () => {
Comment thread
eduardomourar marked this conversation as resolved.
let srcDir: string;

beforeEach(() => {
srcDir = createTempDir();
fs.writeFileSync(path.join(srcDir, "a.txt"), "content");
});

afterEach(() => {
fs.rmSync(srcDir, { recursive: true, force: true });
});

const stack = () =>
new TerraformStack(
Testing.app({ context: { [CANONICAL_ASSET_HASHES]: "true" } }),
"s",
);

test("staged asset is reachable under stacks/<id>, not as a sibling of stacks/", () => {
const s = stack();
const asset = new TerraformAsset(s, "asset", {
path: srcDir,
type: AssetType.DIRECTORY,
});

const outdir = Testing.fullSynth(s);
const stackDir = path.join(outdir, "stacks", s.node.id);

// The asset resolves inside the stack's own directory...
expect(fs.existsSync(path.join(stackDir, asset.path))).toBe(true);
// ...never as a sibling of stacks/ (the historical #380 concern).
expect(fs.existsSync(path.join(outdir, asset.path))).toBe(false);
});
});

describe("TerraformModuleAsset with the canonicalAssetHashes flag", () => {
let rootDir: string;
let moduleA: string;
Expand Down
Loading