Skip to content

Conversation

@Carbonhell
Copy link

@Carbonhell Carbonhell commented Nov 9, 2025

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;
  • send_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 for handle_request. Added a test for handle_request by 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.

  • integrate tests in the CI;
  • figure out if there's a way to properly test send_request_to_s3;
  • (requires review) understand if there's any other meaningful test to implement;

fix: remame compute-static build target to wasip1
fix: pin toolchain to 1.90 due to https://www.fastlystatus.com/incident/378001
tweak: handle version-downloads URL path with/without trailing slash in the same way without permanent redirects
refactor: move request/response log collection to log_line to facilitate testing
…2e tests to test the whole flow in a simple case
@Carbonhell Carbonhell marked this pull request as ready for review November 10, 2025 22:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Write unit tests for static.crates.io function

1 participant