From 45d2f7923fd9660a8190626b1f3f5110ba2c9a7b Mon Sep 17 00:00:00 2001 From: MasterPtato Date: Thu, 21 Mar 2024 23:59:11 +0000 Subject: [PATCH] fix: feature flag more tests --- lib/util/core/src/feature.rs | 4 ++++ svc/api/matchmaker/tests/custom_lobby.rs | 4 ++++ svc/api/route/tests/basic.rs | 8 ++++++++ svc/pkg/debug/ops/email-res/tests/integration.rs | 4 ++++ .../email-verification/ops/complete/tests/integration.rs | 8 ++++++++ .../email-verification/ops/create/tests/integration.rs | 8 ++++++++ svc/pkg/email/ops/send/tests/integration.rs | 4 ++++ .../game/ops/namespace-resolve-url/tests/integration.rs | 4 ++++ .../standalone/watch-requests/tests/integration.rs | 4 ++++ svc/pkg/mm/ops/lobby-player-count/tests/integration.rs | 4 ++++ .../mm/ops/lobby-runtime-aggregate/tests/integration.rs | 4 ++++ svc/pkg/upload/ops/prepare/tests/integration.rs | 3 ++- 12 files changed, 58 insertions(+), 1 deletion(-) diff --git a/lib/util/core/src/feature.rs b/lib/util/core/src/feature.rs index cde75222e..5da7396f0 100644 --- a/lib/util/core/src/feature.rs +++ b/lib/util/core/src/feature.rs @@ -26,3 +26,7 @@ pub fn job_run() -> bool { pub fn billing() -> bool { std::env::var("RIVET_BILLING").ok().is_some() } + +pub fn email() -> bool { + std::env::var("SENDGRID_KEY").ok().is_some() +} diff --git a/svc/api/matchmaker/tests/custom_lobby.rs b/svc/api/matchmaker/tests/custom_lobby.rs index a1a4510e5..0baac3d61 100644 --- a/svc/api/matchmaker/tests/custom_lobby.rs +++ b/svc/api/matchmaker/tests/custom_lobby.rs @@ -8,6 +8,10 @@ use serde_json::json; #[tokio::test(flavor = "multi_thread")] async fn create_custom_lobby() { + if !util::feature::dns() || !util::feature::job_run() { + return; + } + let ctx = Ctx::init().await; { diff --git a/svc/api/route/tests/basic.rs b/svc/api/route/tests/basic.rs index 31b5ad081..60fc56d49 100644 --- a/svc/api/route/tests/basic.rs +++ b/svc/api/route/tests/basic.rs @@ -199,6 +199,10 @@ async fn cdn() { #[tokio::test(flavor = "multi_thread")] async fn job_run() { + if !util::feature::job_run() { + return; + } + struct Namespace { namespace_id: Uuid, domain: String, @@ -315,6 +319,10 @@ mod cdn_suite { #[tokio::test(flavor = "multi_thread")] async fn cdn_all() { + if !util::feature::dns() { + return; + } + let ctx = Ctx::init().await; // Create CDN diff --git a/svc/pkg/debug/ops/email-res/tests/integration.rs b/svc/pkg/debug/ops/email-res/tests/integration.rs index b7cabfb71..27cc1e094 100644 --- a/svc/pkg/debug/ops/email-res/tests/integration.rs +++ b/svc/pkg/debug/ops/email-res/tests/integration.rs @@ -2,6 +2,10 @@ use chirp_worker::prelude::*; #[worker_test] async fn empty(ctx: TestCtx) { + if !util::feature::email() { + return; + } + let email = util::faker::email(); let create_res = op!([ctx] email_verification_create { diff --git a/svc/pkg/email-verification/ops/complete/tests/integration.rs b/svc/pkg/email-verification/ops/complete/tests/integration.rs index 104428058..e2cb69a5f 100644 --- a/svc/pkg/email-verification/ops/complete/tests/integration.rs +++ b/svc/pkg/email-verification/ops/complete/tests/integration.rs @@ -3,6 +3,10 @@ use proto::backend::pkg::*; #[worker_test] async fn correct(ctx: TestCtx) { + if !util::feature::email() { + return; + } + let create_res = op!([ctx] email_verification_create { email: "test@rivet.gg".into(), }) @@ -53,6 +57,10 @@ async fn correct(ctx: TestCtx) { #[worker_test] async fn incorrect(ctx: TestCtx) { + if !util::feature::email() { + return; + } + let create_res = op!([ctx] email_verification_create { email: "test@rivet.gg".into(), }) diff --git a/svc/pkg/email-verification/ops/create/tests/integration.rs b/svc/pkg/email-verification/ops/create/tests/integration.rs index 9a0670195..df036ee55 100644 --- a/svc/pkg/email-verification/ops/create/tests/integration.rs +++ b/svc/pkg/email-verification/ops/create/tests/integration.rs @@ -3,6 +3,10 @@ use proto::backend; #[worker_test] async fn normal(ctx: TestCtx) { + if !util::feature::email() { + return; + } + let res = op!([ctx] email_verification_create { email: "test@rivet.gg".into(), }) @@ -26,6 +30,10 @@ async fn normal(ctx: TestCtx) { #[worker_test] async fn with_game(ctx: TestCtx) { + if !util::feature::email() { + return; + } + let game_res = op!([ctx] faker_game {}).await.unwrap(); let game_id = game_res.game_id.unwrap().as_uuid(); diff --git a/svc/pkg/email/ops/send/tests/integration.rs b/svc/pkg/email/ops/send/tests/integration.rs index c8ac4bbbb..795447b6a 100644 --- a/svc/pkg/email/ops/send/tests/integration.rs +++ b/svc/pkg/email/ops/send/tests/integration.rs @@ -3,6 +3,10 @@ use proto::backend::pkg::*; #[worker_test] async fn empty(ctx: TestCtx) { + if !util::feature::email() { + return; + } + op!([ctx] email_send { from_address: Some(email::send::Address { email: "hello@rivet.gg".into(), diff --git a/svc/pkg/game/ops/namespace-resolve-url/tests/integration.rs b/svc/pkg/game/ops/namespace-resolve-url/tests/integration.rs index 1d23990e6..f3fbfa037 100644 --- a/svc/pkg/game/ops/namespace-resolve-url/tests/integration.rs +++ b/svc/pkg/game/ops/namespace-resolve-url/tests/integration.rs @@ -27,6 +27,10 @@ async fn test_no_ns(ctx: TestCtx) { #[worker_test] async fn test_with_ns(ctx: TestCtx) { + if !util::feature::dns() { + return; + } + let game_data = prepare_game(&ctx).await; for ns in &game_data.namespaces { let domain_main_res = test_url( diff --git a/svc/pkg/load-test/standalone/watch-requests/tests/integration.rs b/svc/pkg/load-test/standalone/watch-requests/tests/integration.rs index a654110bc..883f9e675 100644 --- a/svc/pkg/load-test/standalone/watch-requests/tests/integration.rs +++ b/svc/pkg/load-test/standalone/watch-requests/tests/integration.rs @@ -4,6 +4,10 @@ use ::load_test_watch_requests::run_from_env; #[tokio::test(flavor = "multi_thread")] async fn basic() { + if !util::feature::dns() { + return; + } + tracing_subscriber::fmt() .json() .with_max_level(tracing::Level::INFO) diff --git a/svc/pkg/mm/ops/lobby-player-count/tests/integration.rs b/svc/pkg/mm/ops/lobby-player-count/tests/integration.rs index 26177a3d8..b93502bcb 100644 --- a/svc/pkg/mm/ops/lobby-player-count/tests/integration.rs +++ b/svc/pkg/mm/ops/lobby-player-count/tests/integration.rs @@ -10,6 +10,10 @@ struct TestPlayer { #[worker_test] async fn empty(ctx: TestCtx) { + if !util::feature::job_run() { + return; + } + let lobby_a = op!([ctx] faker_mm_lobby { ..Default::default() }) diff --git a/svc/pkg/mm/ops/lobby-runtime-aggregate/tests/integration.rs b/svc/pkg/mm/ops/lobby-runtime-aggregate/tests/integration.rs index bff682a21..7431943f8 100644 --- a/svc/pkg/mm/ops/lobby-runtime-aggregate/tests/integration.rs +++ b/svc/pkg/mm/ops/lobby-runtime-aggregate/tests/integration.rs @@ -98,6 +98,10 @@ async fn missing_columns(ctx: TestCtx) { #[worker_test] async fn out_of_range(ctx: TestCtx) { + if !util::feature::job_run() { + return; + } + let lobby_res = op!([ctx] faker_mm_lobby { ..Default::default() }) diff --git a/svc/pkg/upload/ops/prepare/tests/integration.rs b/svc/pkg/upload/ops/prepare/tests/integration.rs index 43255939f..4998fcaf3 100644 --- a/svc/pkg/upload/ops/prepare/tests/integration.rs +++ b/svc/pkg/upload/ops/prepare/tests/integration.rs @@ -135,7 +135,8 @@ async fn multipart(ctx: TestCtx) { .map(|i| { tracing::info!("generating part {}", i + 1); - (&mut rng).sample_iter(&Alphanumeric) + (&mut rng) + .sample_iter(&Alphanumeric) .take(CHUNK_SIZE as usize) .map(char::from) .collect::()