Use testcontainers for Rust PostgreSQL tests
Deploy / deploy (push) Successful in 1m45s
CI / Rust Checks (push) Failing after 5m38s
CI / UI Checks (push) Has been skipped
CI / Frontend E2E (push) Has been skipped
CI / Deployment Manifests (push) Has been skipped

This commit is contained in:
github-ops
2026-06-21 03:17:06 +00:00
parent ac45d5dc2d
commit d01c8e1f1a
15 changed files with 1069 additions and 129 deletions
+3 -15
View File
@@ -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}")))