From a7a3d86c123b4cbf5a19c4e15b1675cb50985ee8 Mon Sep 17 00:00:00 2001 From: Daniel Schmidt Date: Fri, 18 Feb 2022 14:57:37 +0100 Subject: [PATCH] refactor: rename and regroup tests --- test/typescript/multiple-stacks/test.ts | 101 ++++++++++++------------ 1 file changed, 51 insertions(+), 50 deletions(-) diff --git a/test/typescript/multiple-stacks/test.ts b/test/typescript/multiple-stacks/test.ts index f6bd3aca41..316357722f 100644 --- a/test/typescript/multiple-stacks/test.ts +++ b/test/typescript/multiple-stacks/test.ts @@ -1,26 +1,26 @@ import { TestDriver, onPosix, onWindows } from "../../test-helper"; -describe("full integration test", () => { +describe("multiple stacks", () => { let driver: TestDriver; beforeAll(async () => { driver = new TestDriver(__dirname); await driver.setupTypescriptProject(); - console.log(driver.workingDirectory); }); - test("synth", async () => { - await driver.synth(); - expect(driver.synthesizedStack("first").toString()).toMatchSnapshot(); - expect(driver.synthesizedStack("second").toString()).toMatchSnapshot(); - }); + describe("CLI-driven workflow", () => { + test("synth", async () => { + await driver.synth(); + expect(driver.synthesizedStack("first").toString()).toMatchSnapshot(); + expect(driver.synthesizedStack("second").toString()).toMatchSnapshot(); + }); - test("synth with json output", async () => { - expect((await driver.synth("--json")).stdout).toMatchSnapshot(); - }); + test("synth with json output", async () => { + expect((await driver.synth("--json")).stdout).toMatchSnapshot(); + }); - test("diff", () => { - expect(driver.diff("first")).toMatchInlineSnapshot(` + test("diff", () => { + expect(driver.diff("first")).toMatchInlineSnapshot(` "Stack: first Resources + NULL_RESOURCE test null_resource.test @@ -30,7 +30,7 @@ describe("full integration test", () => { " `); - expect(driver.diff("second")).toMatchInlineSnapshot(` + expect(driver.diff("second")).toMatchInlineSnapshot(` "Stack: second Resources + NULL_RESOURCE test null_resource.test @@ -40,44 +40,44 @@ describe("full integration test", () => { " `); - expect(() => driver.diff()).toThrowError("Found more than one stack"); - }); + expect(() => driver.diff()).toThrowError("Found more than one stack"); + }); - onPosix("list posix", () => { - expect(driver.list()).toMatchInlineSnapshot(` + onPosix("list posix", () => { + expect(driver.list()).toMatchInlineSnapshot(` "Stack name Path first cdktf.out/stacks/first second cdktf.out/stacks/second " `); - }); + }); - onWindows("list windows", () => { - expect(driver.list()).toMatchInlineSnapshot(` + onWindows("list windows", () => { + expect(driver.list()).toMatchInlineSnapshot(` "Stack name Path first cdktf.out\\\\stacks\\\\first second cdktf.out\\\\stacks\\\\second " `); - }); - - // completions for stacks relies on a manifest.json being present - // so this test must be run after something that synthesizes and - // thus writes a Manifest (like e.g. cdktf list) - test("shell completions complete stacks", async () => { - const { stdout, stderr } = await driver.exec("cdktf", [ - "--get-yargs-completions", - "cdktf", - "diff", - ]); - - expect(stdout).toContain('first:target stack "first"'); - expect(stdout).toContain('second:target stack "second"'); - expect(stderr).toEqual(""); - }); - - test("deploy", () => { - expect(driver.deploy("first")).toMatchInlineSnapshot(` + }); + + // completions for stacks relies on a manifest.json being present + // so this test must be run after something that synthesizes and + // thus writes a Manifest (like e.g. cdktf list) + test("shell completions complete stacks", async () => { + const { stdout, stderr } = await driver.exec("cdktf", [ + "--get-yargs-completions", + "cdktf", + "diff", + ]); + + expect(stdout).toContain('first:target stack "first"'); + expect(stdout).toContain('second:target stack "second"'); + expect(stderr).toEqual(""); + }); + + test("deploy", () => { + expect(driver.deploy("first")).toMatchInlineSnapshot(` " Deploying Stack: first Resources ✔ NULL_RESOURCE test null_resource.test @@ -87,7 +87,7 @@ describe("full integration test", () => { " `); - expect(driver.deploy("second")).toMatchInlineSnapshot(` + expect(driver.deploy("second")).toMatchInlineSnapshot(` " Deploying Stack: second Resources ✔ NULL_RESOURCE test null_resource.test @@ -97,13 +97,13 @@ describe("full integration test", () => { " `); - expect(() => driver.deploy()).toThrowError( - "Found more than one stack, please specify a target stack. Run cdktf with one of these stacks: first, second" - ); - }); + expect(() => driver.deploy()).toThrowError( + "Found more than one stack, please specify a target stack. Run cdktf with one of these stacks: first, second" + ); + }); - test("destroy", () => { - expect(driver.destroy("first")).toMatchInlineSnapshot(` + test("destroy", () => { + expect(driver.destroy("first")).toMatchInlineSnapshot(` " Destroying Stack: first Resources ✔ NULL_RESOURCE test null_resource.test @@ -113,7 +113,7 @@ describe("full integration test", () => { " `); - expect(driver.destroy("second")).toMatchInlineSnapshot(` + expect(driver.destroy("second")).toMatchInlineSnapshot(` " Destroying Stack: second Resources ✔ NULL_RESOURCE test null_resource.test @@ -123,8 +123,9 @@ describe("full integration test", () => { " `); - expect(() => driver.destroy()).toThrowError( - "Found more than one stack, please specify a target stack. Run cdktf with one of these stacks: first, second" - ); + expect(() => driver.destroy()).toThrowError( + "Found more than one stack, please specify a target stack. Run cdktf with one of these stacks: first, second" + ); + }); }); });