Use testcontainers for Rust PostgreSQL tests
This commit is contained in:
@@ -1009,11 +1009,7 @@ fn usage_bucket_sql(bucket: crate::model::UsageBucket) -> &'static str {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::{
|
||||
collections::BTreeMap,
|
||||
env,
|
||||
time::{SystemTime, UNIX_EPOCH},
|
||||
};
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use crank_core::{
|
||||
AgentId, AgentOperationBinding, AgentStatus, AgentVersion, ApiKeyHeaderAuthConfig,
|
||||
@@ -1917,21 +1913,13 @@ mod tests {
|
||||
|
||||
impl TestDatabase {
|
||||
async fn new() -> Self {
|
||||
let database_url = env::var("TEST_DATABASE_URL")
|
||||
.expect("TEST_DATABASE_URL must point to a reachable PostgreSQL database");
|
||||
let database_url = crank_test_support::postgres_database_url().await.to_owned();
|
||||
let admin_pool = PgPoolOptions::new()
|
||||
.max_connections(1)
|
||||
.connect(&database_url)
|
||||
.await
|
||||
.unwrap();
|
||||
let schema = format!(
|
||||
"test_registry_{}_{}",
|
||||
std::process::id(),
|
||||
SystemTime::now()
|
||||
.duration_since(UNIX_EPOCH)
|
||||
.unwrap()
|
||||
.as_nanos()
|
||||
);
|
||||
let schema = crank_test_support::unique_schema_name("test_registry");
|
||||
|
||||
admin_pool
|
||||
.execute(sqlx::query(&format!("create schema {schema}")))
|
||||
|
||||
Reference in New Issue
Block a user