You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Right now there are no unit tests for the rootfs image scanning Lambda. While this is non-critical infrastructure and the function is fairly simple, unit test coverage for the function would surely be an enhancement to the overall testing profile of this package.
A solution could define a class like this with a boto3 resource to be easily mocked:
classSnsTopicClass:
""" AWS SNS Topic Resource Class """def__init__(self, sns_topic_resource):
self.resource=sns_topic_resource["resource"]
self.topic_arn=sns_topic_resource["topic_arn"]
self.topic=self.resource.Topic(self.topic_arn)
# [1] Globally scoped resources# Initialize the resources once per Lambda execution environment by using global scope._LAMBDA_SNS_TOPIC_RESOURCE= { "resource" : resource('sns'),
"topic_arn" : os.environ.get("SNS_ARN","NONE") }
Alternatively, given this project is mainly TypeScript, the lambda function could be rewritten in TS to get the built in benefit of all testing tooling already living with the project, i.e. not having to maintain a python virtual environment or similar for testing this both locally for devs and in the actual pipeline defined in this project.
The text was updated successfully, but these errors were encountered:
Right now there are no unit tests for the rootfs image scanning Lambda. While this is non-critical infrastructure and the function is fairly simple, unit test coverage for the function would surely be an enhancement to the overall testing profile of this package.
A solution could define a class like this with a boto3 resource to be easily mocked:
Alternatively, given this project is mainly TypeScript, the lambda function could be rewritten in TS to get the built in benefit of all testing tooling already living with the project, i.e. not having to maintain a python virtual environment or similar for testing this both locally for devs and in the actual pipeline defined in this project.
The text was updated successfully, but these errors were encountered: