-
Notifications
You must be signed in to change notification settings - Fork 247
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
factors: Update runtime config and tests #2686
Conversation
Signed-off-by: Lann Martin <[email protected]>
type EnvFetcherFn = Box<dyn Fn(&str) -> Result<String, VarError> + Send + Sync>; | ||
|
||
/// A config Provider that uses environment variables. | ||
pub struct EnvVariablesProvider { | ||
prefix: Option<String>, | ||
env_fetcher: Box<dyn Fn(&str) -> Result<String, VarError> + Send + Sync>, | ||
env_fetcher: EnvFetcherFn, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clippy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! I'm going to merge this just so we don't run into any conflicts down the line.
let mut env = Self::default(); | ||
env.manifest.extend(manifest_merge); | ||
env | ||
pub fn extend_manifest(mut self, manifest_merge: toml::Table) -> Self { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to be mimicking a builder pattern. Normally this would be a separate struct with a build
method, but I think in this case, just mutating the TestEnvironment
is fine. Just wanted to note it here as a place for potential future change.
factors, | ||
TomlRuntimeSource::new(&runtime_config, sqlite_config), | ||
) | ||
let env = TestEnvironment::new(factors) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let env = TestEnvironment::new(factors) | |
let _ = TestEnvironment::new(factors) |
I'm surprised this doesn't lead to a warning?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
env
is used at 77
I swear this started out as a focused commit...
Anyway: this is a random grab-bag of changes to simplify and homogenize factors runtime config and tests:
RuntimeFactors::configure_app
#[derive(Default)]
to derivedRuntimeFactors
' runtime configs; replace()
as an "empty source" withDefault::default()
TestEnvironment
to use a builder-style interfacefactor_test.rs
(commence bikeshedding!)WasiFactor
deps