Skip to content

Commit e9c0447

Browse files
committed
Remove db_pool function
1 parent 82dcd5d commit e9c0447

File tree

2 files changed

+20
-29
lines changed

2 files changed

+20
-29
lines changed

database/src/pool.rs

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -474,8 +474,7 @@ mod tests {
474474
// This is essentially testing the database testing framework is
475475
// wired up correctly. Though makes sense that there should be
476476
// an empty vector returned if there are no pstats.
477-
let db = ctx.db_pool();
478-
let result = db.connection().await.get_pstats(&[], &[]).await;
477+
let result = ctx.db().get_pstats(&[], &[]).await;
479478
let expected: Vec<Vec<Option<f64>>> = vec![];
480479

481480
assert_eq!(result, expected);
@@ -487,21 +486,19 @@ mod tests {
487486
#[tokio::test]
488487
async fn artifact_storage() {
489488
run_db_test(|ctx| async {
490-
let db = ctx.db_pool();
489+
let db = ctx.db();
491490
let time = chrono::DateTime::from_str("2021-09-01T00:00:00.000Z").unwrap();
492491

493492
let artifact_one = ArtifactId::from(create_commit("abc", time, CommitType::Master));
494493
let artifact_two = ArtifactId::Tag("nightly-2025-05-14".to_string());
495494

496-
let artifact_one_id_number = db.connection().await.artifact_id(&artifact_one).await;
497-
let artifact_two_id_number = db.connection().await.artifact_id(&artifact_two).await;
495+
let artifact_one_id_number = db.artifact_id(&artifact_one).await;
496+
let artifact_two_id_number = db.artifact_id(&artifact_two).await;
498497

499498
// We cannot arbitrarily add random sizes to the artifact size
500499
// table, as there is a constraint that the artifact must actually
501500
// exist before attaching something to it.
502501

503-
let db = db.connection().await;
504-
505502
// Artifact one inserts
506503
db.record_artifact_size(artifact_one_id_number, "llvm.so", 32)
507504
.await;
@@ -531,8 +528,8 @@ mod tests {
531528
#[tokio::test]
532529
async fn multiple_requests_same_sha() {
533530
run_postgres_test(|ctx| async {
534-
let db = ctx.db_pool();
535-
let db = db.connection().await;
531+
let db = ctx.db();
532+
536533
db.insert_benchmark_request(&BenchmarkRequest::create_master(
537534
"a-sha-1",
538535
"parent-sha-1",
@@ -555,7 +552,7 @@ mod tests {
555552
#[tokio::test]
556553
async fn multiple_non_completed_try_requests() {
557554
run_postgres_test(|ctx| async {
558-
let db = ctx.db_pool().connection().await;
555+
let db = ctx.db();
559556
let target = Target::X86_64UnknownLinuxGnu;
560557
let collector_name = "collector-1";
561558
let benchmark_set = 1;
@@ -597,8 +594,7 @@ mod tests {
597594
#[tokio::test]
598595
async fn multiple_master_requests_same_pr() {
599596
run_postgres_test(|ctx| async {
600-
let db = ctx.db_pool();
601-
let db = db.connection().await;
597+
let db = ctx.db();
602598

603599
db.insert_benchmark_request(&BenchmarkRequest::create_master(
604600
"a-sha-1",
@@ -626,7 +622,7 @@ mod tests {
626622
#[tokio::test]
627623
async fn load_pending_benchmark_requests() {
628624
run_postgres_test(|ctx| async {
629-
let db = ctx.db_pool().connection().await;
625+
let db = ctx.db();
630626
let time = chrono::DateTime::from_str("2021-09-01T00:00:00.000Z").unwrap();
631627
let target = Target::X86_64UnknownLinuxGnu;
632628
let collector_name = "collector-1";
@@ -672,8 +668,7 @@ mod tests {
672668
#[tokio::test]
673669
async fn attach_shas_to_try_benchmark_request() {
674670
run_postgres_test(|ctx| async {
675-
let db = ctx.db_pool();
676-
let db = db.connection().await;
671+
let db = ctx.db();
677672

678673
let req = BenchmarkRequest::create_try_without_artifacts(42, "", "");
679674

@@ -712,8 +707,8 @@ mod tests {
712707
#[tokio::test]
713708
async fn enqueue_benchmark_job() {
714709
run_postgres_test(|ctx| async {
715-
let db = ctx.db_pool();
716-
let db = db.connection().await;
710+
let db = ctx.db();
711+
717712
let time = chrono::DateTime::from_str("2021-09-01T00:00:00.000Z").unwrap();
718713
let benchmark_request =
719714
BenchmarkRequest::create_master("sha-1", "parent-sha-1", 42, time);
@@ -743,7 +738,7 @@ mod tests {
743738
#[tokio::test]
744739
async fn get_compile_test_cases_with_data() {
745740
run_db_test(|ctx| async {
746-
let db = ctx.db_pool().connection().await;
741+
let db = ctx.db();
747742

748743
let collection = db.collection_id("test").await;
749744
let artifact = db
@@ -802,7 +797,7 @@ mod tests {
802797
#[tokio::test]
803798
async fn get_collector_config_error_if_not_exist() {
804799
run_postgres_test(|ctx| async {
805-
let db = ctx.db_pool().connection().await;
800+
let db = ctx.db();
806801

807802
let collector_config_result = db.start_collector("collector-1", "foo").await.unwrap();
808803

@@ -816,7 +811,7 @@ mod tests {
816811
#[tokio::test]
817812
async fn add_collector_config() {
818813
run_postgres_test(|ctx| async {
819-
let db = ctx.db_pool().connection().await;
814+
let db = ctx.db();
820815

821816
let mut inserted_config = db
822817
.add_collector_config("collector-1", Target::X86_64UnknownLinuxGnu, 1, true)
@@ -841,7 +836,7 @@ mod tests {
841836
#[tokio::test]
842837
async fn dequeue_benchmark_job_empty_queue() {
843838
run_postgres_test(|ctx| async {
844-
let db = ctx.db_pool().connection().await;
839+
let db = ctx.db();
845840

846841
let benchmark_job_result = db
847842
.dequeue_benchmark_job(
@@ -862,7 +857,7 @@ mod tests {
862857
#[tokio::test]
863858
async fn dequeue_benchmark_job() {
864859
run_postgres_test(|ctx| async {
865-
let db = ctx.db_pool().connection().await;
860+
let db = ctx.db();
866861
let time = chrono::DateTime::from_str("2021-09-01T00:00:00.000Z").unwrap();
867862

868863
let collector_config = db
@@ -931,7 +926,7 @@ mod tests {
931926
#[tokio::test]
932927
async fn mark_request_as_complete_empty() {
933928
run_postgres_test(|ctx| async {
934-
let db = ctx.db_pool().connection().await;
929+
let db = ctx.db();
935930
let time = chrono::DateTime::from_str("2021-09-01T00:00:00.000Z").unwrap();
936931

937932
let insert_result = db
@@ -956,7 +951,7 @@ mod tests {
956951
#[tokio::test]
957952
async fn mark_request_as_complete() {
958953
run_postgres_test(|ctx| async {
959-
let db = ctx.db_pool().connection().await;
954+
let db = ctx.db();
960955
let time = chrono::DateTime::from_str("2021-09-01T00:00:00.000Z").unwrap();
961956
let benchmark_set = BenchmarkSet(0u32);
962957
let tag = "sha-1";
@@ -1034,7 +1029,7 @@ mod tests {
10341029
#[tokio::test]
10351030
async fn get_collector_configs() {
10361031
run_postgres_test(|ctx| async {
1037-
let db = ctx.db_pool().connection().await;
1032+
let db = ctx.db();
10381033
let target = Target::X86_64UnknownLinuxGnu;
10391034

10401035
let benchmark_set_one = BenchmarkSet(0u32);

database/src/tests/mod.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,6 @@ impl TestContext {
9696
}
9797
}
9898

99-
pub fn db_pool(&self) -> &Pool {
100-
&self.pool
101-
}
102-
10399
pub fn db(&self) -> &dyn Connection {
104100
self.connection.as_ref()
105101
}

0 commit comments

Comments
 (0)