-
-
Notifications
You must be signed in to change notification settings - Fork 222
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ref(tests): Decouple test env vars from trycmd code
As a part of #2194, I intend to introduce the [`assert_cmd` crate](https://docs.rs/assert_cmd/latest/assert_cmd/) to have more control over how the assertions for the chunk upload tests are run. This control would be difficult to achieve with `trycmd`. So, here, I am splitting off the logic for setting environment variables to make it also reusable for `assert_cmd` tests
- Loading branch information
1 parent
632ab83
commit c46bb3c
Showing
3 changed files
with
41 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
//! Utilities for setting environment variables in integration tests. | ||
|
||
use std::borrow::Cow; | ||
|
||
/// Set the environment variables, which should be set for all integration tests, | ||
/// using the provided setter function. | ||
/// The setter function takes as parameters the environment variable name, and the | ||
/// value to set it to, in that order. | ||
pub fn set(mut setter: impl FnMut(&'static str, Cow<'static, str>)) { | ||
let dsn = format!("http://test@{}/1337", mockito::server_address()).into(); | ||
|
||
setter("SENTRY_INTEGRATION_TEST", "1".into()); | ||
setter("SENTRY_ORG", "wat-org".into()); | ||
setter("SENTRY_PROJECT", "wat-project".into()); | ||
setter("SENTRY_URL", mockito::server_url().into()); | ||
setter("SENTRY_DSN", dsn); | ||
} | ||
|
||
/// Set the auth token environment variable using the provided setter function. | ||
pub fn set_auth_token(setter: impl FnOnce(&'static str, Cow<'static, str>)) { | ||
setter( | ||
"SENTRY_AUTH_TOKEN", | ||
"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef".into(), | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
//! A collection of utilities for integration tests. | ||
|
||
pub mod env; |