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

test: enable server-side config from context #3954

Merged
merged 2 commits into from
Jun 18, 2024

Conversation

zepatrik
Copy link
Member

With this change we can use the context-based test configs server side, e.g. in integration tests.

Comment on lines 83 to 86
cID := r.Header.Get("Test-Config-Id")
if config, ok := t.configs[uuid.FromStringOrNil(cID)]; ok {
r = r.WithContext(WithConfigValues(r.Context(), config...))
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The handler looks up the config ID from the request header and adds the config to the request context server-side if it found it.

}

func (t *ConfigurableTestHandler) UseConfigValues(r *http.Request, values ...map[string]any) *http.Request {
return t.UseConfig(r, t.RegisterConfig(values...))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registering the config values and setting the config header on the request (client side).

Copy link

codecov bot commented Jun 17, 2024

Codecov Report

Attention: Patch coverage is 97.29730% with 2 lines in your changes missing coverage. Please review.

Project coverage is 78.20%. Comparing base (61f87d9) to head (979ac92).
Report is 1 commits behind head on master.

Files Patch % Lines
driver/config/testhelpers/config.go 97.01% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3954      +/-   ##
==========================================
+ Coverage   78.18%   78.20%   +0.02%     
==========================================
  Files         363      363              
  Lines       25443    25486      +43     
==========================================
+ Hits        19892    19931      +39     
- Misses       4030     4032       +2     
- Partials     1521     1523       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@zepatrik zepatrik merged commit e0001b0 into master Jun 18, 2024
29 checks passed
@zepatrik zepatrik deleted the test/context-config-serverside branch June 18, 2024 09:18
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