Skip to content

Commit

Permalink
refactor: rename and regroup tests
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielMSchmidt committed Feb 18, 2022
1 parent 181c2f3 commit a7a3d86
Showing 1 changed file with 51 additions and 50 deletions.
101 changes: 51 additions & 50 deletions test/typescript/multiple-stacks/test.ts
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -97,13 +97,13 @@ describe("full integration test", () => {
"
`);

expect(() => driver.deploy()).toThrowError(
"Found more than one stack, please specify a target stack. Run cdktf <verb> <stack> with one of these stacks: first, second"
);
});
expect(() => driver.deploy()).toThrowError(
"Found more than one stack, please specify a target stack. Run cdktf <verb> <stack> 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
Expand All @@ -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
Expand All @@ -123,8 +123,9 @@ describe("full integration test", () => {
"
`);

expect(() => driver.destroy()).toThrowError(
"Found more than one stack, please specify a target stack. Run cdktf <verb> <stack> with one of these stacks: first, second"
);
expect(() => driver.destroy()).toThrowError(
"Found more than one stack, please specify a target stack. Run cdktf <verb> <stack> with one of these stacks: first, second"
);
});
});
});

0 comments on commit a7a3d86

Please sign in to comment.