Skip to content

Commit

Permalink
test: Add first test for GithubCustomResource (pepperize#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
WtfJoke committed Nov 8, 2022
1 parent d283c83 commit 11e4775
Show file tree
Hide file tree
Showing 2 changed files with 316 additions and 1 deletion.
265 changes: 265 additions & 0 deletions test/__snapshots__/github-custom-resource.test.ts.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

52 changes: 51 additions & 1 deletion test/github-custom-resource.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,53 @@
import { App, Stack } from "aws-cdk-lib";
import { Match, Template } from "aws-cdk-lib/assertions";
import { Secret } from "aws-cdk-lib/aws-secretsmanager";
import { Construct } from "constructs";
import { AuthOptions } from "../src/auth";
import { GithubCustomResource } from "../src/github-custom-resource";

describe("GithubCustomResource", () => {
it("", () => {});
it("Should match snapshot", () => {
// Given
const app = new App();
const stack = new GithubCustomResourceTestStack(app, "GithubTestStack");

// When
const template = Template.fromStack(stack);

// Then
expect(template).toMatchSnapshot();
});

it("Should contain GithubCustomResource with appAuth", () => {
// Given
const app = new App();
const stack = new GithubCustomResourceTestStack(app, "GithubTestStack");

// When
const template = Template.fromStack(stack);

// Then
template.hasResourceProperties("AWS::SecretsManager::Secret", { Description: "GithubAppAuthSecret" });
template.hasResourceProperties("AWS::CloudFormation::CustomResource", {
Auth: {
secret: {
Ref: Match.stringLikeRegexp("githubAuthSecret"),
},
strategy: "auth-app",
},
});
});
});

class GithubCustomResourceTestStack extends Stack {
constructor(scope: Construct, id: string) {
super(scope, id);

const secret = new Secret(this, "githubAuthSecret", {
description: "GithubAppAuthSecret",
});
new GithubCustomResource(this, "CR", {
authOptions: AuthOptions.appAuth(secret),
});
}
}

0 comments on commit 11e4775

Please sign in to comment.