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

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 committed Nov 25, 2024
1 parent 7cfe0c7 commit e4e4b0c
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/D4B4539E8559909F9D964C2AE3DC3E41/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": "D4B4539E8559909F9D964C2AE3DC3E41"
"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 e4e4b0c

Please sign in to comment.