Skip to content

Commit

Permalink
Add compiletime test case for operation types
Browse files Browse the repository at this point in the history
  • Loading branch information
boxbeam committed Apr 24, 2024
1 parent e567857 commit 1d7720f
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions ee/tabby-db/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,7 @@ mod tests {
let db = DbConn::new_in_memory().await.unwrap();

let time = DateTimeUtc::now();

let time_str = time.as_sqlite_datetime();
let sql_time: String = sqlx::query_scalar::<_, String>("SELECT ?;")
.bind(time)
Expand All @@ -421,6 +422,12 @@ mod tests {
.await
.unwrap();
assert_eq!(sql_time, DateTimeUtc::now().as_sqlite_datetime());

// No assertions, these will fail at compiletime if adding/subtracting from these types
// yields DateTime<Utc>, which could be dangerous
let time = DateTimeUtc::now();
let _added_time: DateTimeUtc = time.clone() + Duration::milliseconds(1);
let _subbed_time: DateTimeUtc = time - Duration::milliseconds(1);
}
}

Expand Down

0 comments on commit 1d7720f

Please sign in to comment.