Skip to content

Commit

Permalink
add fallback env vars for testing SQS
Browse files Browse the repository at this point in the history
Currently running `cargo test` first requires a few env vars being set.

This PR adds defaults matching the SQS emulator config we use via
docker-compose so that setting the env vars can still be used as
overrides, but otherwise `cargo test` should _Just Work_.
  • Loading branch information
svix-onelson committed Aug 10, 2023
1 parent 1a6d143 commit ab9fcd6
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions omniqueue/tests/sqs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,24 @@ use omniqueue::{
use serde::{Deserialize, Serialize};

const ROOT_URL: &str = "http://localhost:9324";
const DEFAULT_CFG: [(&str, &str); 3] = [
("AWS_DEFAULT_REGION", "localhost"),
("AWS_ACCESS_KEY_ID", "x"),
("AWS_SECRET_ACCESS_KEY", "x"),
];

/// Returns a [`QueueBuilder`] configured to connect to the SQS instance spawned by the file
/// `testing-docker-compose.yaml` in the root of the repository.
///
/// Additionally this will make a temporary queue on that instance for the duration of the test such
/// as to ensure there is no stealing.w
async fn make_test_queue() -> QueueBuilder<SqsQueueBackend, Static> {
for (var, val) in &DEFAULT_CFG {
if std::env::var(var).is_err() {
std::env::set_var(var, val);
}
}

let config = aws_config::from_env().endpoint_url(ROOT_URL).load().await;
let client = Client::new(&config);

Expand Down

0 comments on commit ab9fcd6

Please sign in to comment.