Skip to content

Commit

Permalink
fix: plan changes (#175)
Browse files Browse the repository at this point in the history
* fix: re-running pre-commit to generate changes

* fix: issues from last pr

Use string interpolation, add mocking for conftest-checks to tests.

* chore: autofmt

* fix: adding back in blank line
  • Loading branch information
CalvinRodo authored Mar 21, 2023
1 parent afeda91 commit 26fbdfe
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 6 deletions.
4 changes: 2 additions & 2 deletions dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/action.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ const action = async () => {
{
key: "conftest",
depends: "show-json-out",
exec: "conftest test plan.json --no-color --update ${conftestChecks}",
exec: `conftest test plan.json --no-color --update ${conftestChecks}`,
output: true,
},
];
Expand Down
1 change: 1 addition & 0 deletions src/github.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const commentTemplate = `## {{ title }}
**{{ "✅" if results.plan.isSuccess else "❌" }}   Terraform Plan:** \`{{ "success" if results.plan.isSuccess else "failed" }}\`
{% if not skipConftest -%}
**{{ "✅" if results.conftest.isSuccess else "❌" }}   Conftest:** \`{{ "success" if results.conftest.isSuccess else "failed" }}\`
{% endif -%}
{% endif -%}
{% if not results.init.isSuccess -%}
Expand Down
2 changes: 1 addition & 1 deletion src/policy/policy.js

Large diffs are not rendered by default.

Binary file modified src/policy/policy.wasm
Binary file not shown.
16 changes: 15 additions & 1 deletion test/action.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ describe("action", () => {
test("default flow", async () => {
execCommand.mockReturnValue({ isSuccess: true, output: "{}" });
when(core.getInput).calledWith("directory").mockReturnValue("foo");
when(core.getInput)
.calledWith("conftest-checks")
.mockReturnValue(
"git::https://github.com/cds-snc/opa_checks.git//aws_terraform"
);
when(core.getMultilineInput)
.calledWith("terraform-init")
.mockReturnValue([
Expand Down Expand Up @@ -114,6 +119,11 @@ describe("action", () => {
test("terragrunt flow", async () => {
execCommand.mockReturnValue({ isSuccess: true, output: "{}" });
when(core.getInput).calledWith("directory").mockReturnValue("bar");
when(core.getInput)
.calledWith("conftest-checks")
.mockReturnValue(
"git::https://github.com/cds-snc/opa_checks.git//aws_terraform"
);
when(core.getBooleanInput).calledWith("terragrunt").mockReturnValue(true);

await action();
Expand Down Expand Up @@ -254,7 +264,11 @@ describe("action", () => {
test("failed command", async () => {
execCommand.mockReturnValue({ isSuccess: false, output: "" });
when(core.getInput).calledWith("directory").mockReturnValue("foo");

when(core.getInput)
.calledWith("conftest-checks")
.mockReturnValue(
"git::https://github.com/cds-snc/opa_checks.git//aws_terraform"
);
await action();

expect(core.setFailed.mock.calls.length).toBe(1);
Expand Down

0 comments on commit 26fbdfe

Please sign in to comment.