Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Add first test for GithubCustomResource (#5) #30

Merged
merged 2 commits into from
Nov 14, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
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),
});
}
}