Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/inject value for tentative in simulator #344

Merged
merged 5 commits into from
Jul 31, 2024

Conversation

ysugimoto
Copy link
Owner

@ysugimoto ysugimoto commented Jul 31, 2024

This PR enables to inject/override variables that returns tentative values written in https://github.com/ysugimoto/falco/blob/main/docs/variables.md for testing.
Sometimes the user would like to check the if branch by some fastly predefined variables so it can do testing by injecting suitable values.

Syntax

This feature enables only in testing:

sub test_override_server_region {
  // Override server.region variable value
  testing.inject_variable("server.region", "ASIA");
  testing.call_subroutine("vcl_recv");

  assert.equal(req.http.Region, "ASIA");
}

By calling testing.inject_variable with variable name and override value, the simulator looks up that value and return it if found.
Note that this function could override tentative values which are written in https://github.com/ysugimoto/falco/blob/main/docs/variables.md, typical variables could not override.

@ysugimoto ysugimoto changed the title Feat/inject value for tantitive in simulator Feat/inject value for tentative in simulator Jul 31, 2024
@ysugimoto ysugimoto merged commit 3151b1f into main Jul 31, 2024
3 checks passed
@ysugimoto ysugimoto deleted the feat/inject-value-for-tantitive-in-simulator branch July 31, 2024 09:12
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.

1 participant