tests(compute-static): add basic unit tests #801
+313
−117
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #401 .
This PR adds a few basic unit tests with Viceroy, a local runner for Fastly compute functions. There are a few functions I couldn't test:
set_ttl: there's no way to retrieve the TTL set on a Request struct, and the function itself is trivial;Added a test forsend_request_to_s3: this function sends a HTTP request to the backend, and Viceroy does not allow intercepting them (see related issue). This also prevents implementing a test forhandle_request.handle_requestby starting a small Python HTTP server in background when running tests.While working on this, I noticed the build target was still set to
wasm32-wasi(see here), which was breaking builds due to the target not being found - I've renamed it accordingly.Also, I couldn't build the function either with the latest version of Rust (1.91) due to an ongoing incident with Fastly. I've pinned the version to 1.90 to allow builds, again.
The tests have been integrated in the CI as part of the "Rust projects" job, although this step takes slightly less than 6 minutes due to the installation of Viceroy, mostly. If that's too much time, I can look into caching.
send_request_to_s3;