Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkMcCulloh committed Apr 14, 2024
1 parent 7277f30 commit 5bfaa63
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions libs/wingsdk/test/target-tf-gcp/function.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { readdirSync, readFileSync, existsSync } from "fs";
import { join } from "path";
import * as cdktf from "cdktf";
import { test, expect } from "vitest";
import { Function } from "../../src/cloud";
Expand All @@ -24,6 +26,22 @@ test("basic function", () => {
new Function(app, "Function", inflight);
const output = app.synth();

const functionOutDir = readdirSync(app.workdir, {
recursive: true,
withFileTypes: true,
}).find((d) => d.isDirectory())!;
const packageJson = JSON.parse(
readFileSync(
join(app.workdir, functionOutDir.name, "package.json"),
"utf-8"
)
);
const indexFilename = "index.cjs";
expect(packageJson.main).toBe(indexFilename);
expect(
existsSync(join(app.workdir, functionOutDir.name, indexFilename))
).toBeTruthy();

// THEN
expect(tfResourcesOf(output)).toEqual([
"google_cloudfunctions_function",
Expand Down

0 comments on commit 5bfaa63

Please sign in to comment.