Skip to content

Commit

Permalink
fix: feature flag more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MasterPtato committed Mar 21, 2024
1 parent 843a3c7 commit 45d2f79
Show file tree
Hide file tree
Showing 12 changed files with 58 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lib/util/core/src/feature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
4 changes: 4 additions & 0 deletions svc/api/matchmaker/tests/custom_lobby.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

{
Expand Down
8 changes: 8 additions & 0 deletions svc/api/route/tests/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions svc/pkg/debug/ops/email-res/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 8 additions & 0 deletions svc/pkg/email-verification/ops/complete/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
})
Expand Down Expand Up @@ -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(),
})
Expand Down
8 changes: 8 additions & 0 deletions svc/pkg/email-verification/ops/create/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
})
Expand All @@ -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();

Expand Down
4 changes: 4 additions & 0 deletions svc/pkg/email/ops/send/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
4 changes: 4 additions & 0 deletions svc/pkg/game/ops/namespace-resolve-url/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions svc/pkg/mm/ops/lobby-player-count/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
})
Expand Down
4 changes: 4 additions & 0 deletions svc/pkg/mm/ops/lobby-runtime-aggregate/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
})
Expand Down
3 changes: 2 additions & 1 deletion svc/pkg/upload/ops/prepare/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<String>()
Expand Down

0 comments on commit 45d2f79

Please sign in to comment.