
Answer-first summary for fast verification
Answer: Install the Functions Frameworks library, and configure the Cloud Function on localhost. Make a copy of the function, and make edits to the new version. Test the new version using curl.
The correct approach is to use the Functions Framework for local development and testing, as recommended by Google. Option C suggests installing the Functions Framework library to configure the Cloud Function locally, which allows rapid iteration without deploying to Google Cloud after every code change. By running the function locally, developers can test it using tools like curl with mock requests that simulate the actual trigger payload (e.g., a Cloud Storage event). This avoids delays caused by deploying to the cloud and aligns with best practices for efficient testing. Other options, like modifying triggers (B) or testing in production (D), introduce unnecessary complexity or risk. Option A relies on Cloud Audit Logs, which is not a testing-focused solution.
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
How can your team optimize the testing and development of a Cloud Storage-triggered Cloud Function while adhering to Google's recommended best practices?
A
Create a new Cloud Function that is triggered when Cloud Audit Logs detects the cloudfunctions.functions.sourceCodeSet operation in the original Cloud Function. Send mock requests to the new function to evaluate the functionality.
B
Make a copy of the Cloud Function, and rewrite the code to be HTTP-triggered. Edit and test the new version by triggering the HTTP endpoint. Send mock requests to the new function to evaluate the functionality.
C
Install the Functions Frameworks library, and configure the Cloud Function on localhost. Make a copy of the function, and make edits to the new version. Test the new version using curl.
D
Make a copy of the Cloud Function in the Google Cloud console. Use the Cloud console's in-line editor to make source code changes to the new function. Modify your web application to call the new function, and test the new version in production
No comments yet.