Skip to content

Commit 43c0c4b

Browse files
committed
PR feedback; use Duration type
1 parent d21659f commit 43c0c4b

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

database/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -814,7 +814,7 @@ pub enum BenchmarkRequestStatus {
814814
InProgress,
815815
Completed {
816816
completed_at: DateTime<Utc>,
817-
duration_ms: u32,
817+
duration: Duration,
818818
},
819819
}
820820

@@ -846,9 +846,9 @@ impl BenchmarkRequestStatus {
846846
completed_at: completion_date.ok_or_else(|| {
847847
anyhow!("No completion date for a completed BenchmarkRequestStatus")
848848
})?,
849-
duration_ms: duration_ms.ok_or_else(|| {
849+
duration: Duration::from_millis(duration_ms.ok_or_else(|| {
850850
anyhow!("No completion duration for a completed BenchmarkRequestStatus")
851-
})? as u32,
851+
})? as u64),
852852
}),
853853
_ => Err(anyhow!("Unknown BenchmarkRequestStatus `{text}`")),
854854
}

database/src/pool.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -973,6 +973,9 @@ mod tests {
973973

974974
assert_eq!(job.request_tag(), benchmark_request.tag().unwrap());
975975

976+
/* Make the job take some amount of time */
977+
std::thread::sleep(Duration::from_millis(1000));
978+
976979
/* Mark the job as complete */
977980
db.mark_benchmark_job_as_completed(job.id(), BenchmarkJobConclusion::Success)
978981
.await
@@ -994,10 +997,10 @@ mod tests {
994997
req.status(),
995998
BenchmarkRequestStatus::Completed { .. }
996999
));
997-
let BenchmarkRequestStatus::Completed { duration_ms, .. } = req.status() else {
1000+
let BenchmarkRequestStatus::Completed { duration, .. } = req.status() else {
9981001
unreachable!();
9991002
};
1000-
assert!(duration_ms >= 1);
1003+
assert!(duration >= Duration::from_millis(1000));
10011004

10021005
let completed_index = db.load_benchmark_request_index().await.unwrap();
10031006
assert!(completed_index.contains_tag("sha-1"));

0 commit comments

Comments
 (0)