Skip to content

Commit

Permalink
fix: ignore function hash in regression test as the hash changes with…
Browse files Browse the repository at this point in the history
… updated dependencies that affect the bundled lambda code (#231)

We can safely ignore this hash as we don't need to test whether the
bundler works, we only care about the structure of the terraform output
being correct
  • Loading branch information
ansgarm authored Nov 25, 2024
1 parent 191e228 commit 0ceaf34
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions test/__snapshots__/test-against-regression.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -178,12 +178,12 @@ exports[`Tests against regression of synth output has no change in PostsStack Co
"DYNAMODB_TABLE_NAME": "\${aws_dynamodb_table.posts_storage_table_50F8EECB.name}"
}
},
"filename": "assets/posts_api_code_lambda-asset_7F9E9FED/8709451AE9543AF31FCAFB7AE82D206E/archive.zip",
"filename": "assets/posts_api_code_lambda-asset_7F9E9FED/DUMMY_HASH/archive.zip",
"function_name": "sls-example-posts-api-developmentregression-test",
"handler": "index.handler",
"role": "\${aws_iam_role.posts_api_lambda-exec_B42627E0.arn}",
"runtime": "nodejs14.x",
"source_code_hash": "8709451AE9543AF31FCAFB7AE82D206E"
"source_code_hash": "DUMMY_HASH"
}
},
"aws_lambda_permission": {
Expand Down
7 changes: 7 additions & 0 deletions test/test-against-regression.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ describe("Tests against regression of synth output", () => {
});
const stackSynth = JSON.parse(Testing.synth(stack));
delete stackSynth["terraform"]

// this hash changes whenever dependencies are updated that affect the compiled lambda function
const actualHash = stackSynth.resource.aws_lambda_function.posts_api_7D5242CA.source_code_hash;
stackSynth.resource.aws_lambda_function.posts_api_7D5242CA.source_code_hash = "DUMMY_HASH";
stackSynth.resource.aws_lambda_function.posts_api_7D5242CA.filename =
stackSynth.resource.aws_lambda_function.posts_api_7D5242CA.filename.replace(actualHash, "DUMMY_HASH");

expect(JSON.stringify(stackSynth, null, 2)).toMatchSnapshot();
});
});

0 comments on commit 0ceaf34

Please sign in to comment.