fix(import): подтвердить обязательные гарантии второго эпика
This commit is contained in:
1 parent
31f6f00d3b
commit
ad23cd9a46
33 files changed
+3328
-18
No files matched your search
@@ -0,0 +1,49 @@
|
||||
//! Read-only database observation for the local Playwright harness.
|
||||
//! This example is never packaged as an application endpoint or executable.
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
let workspace = std::env::args().nth(1).expect("test workspace argument");
|
||||
assert!(
|
||||
!workspace.is_empty()
|
||||
&& workspace.len() <= 128
|
||||
&& workspace
|
||||
.bytes()
|
||||
.all(|byte| byte.is_ascii_alphanumeric() || b"_-".contains(&byte)),
|
||||
"invalid test workspace argument"
|
||||
);
|
||||
let config = crank_config::parse_migrator(
|
||||
crank_config::ConfigSource::from_os_for_migrator().expect("test configuration source"),
|
||||
)
|
||||
.expect("test database configuration");
|
||||
let database = config.database;
|
||||
let options = if let Some(url) = &database.url {
|
||||
url.expose_secret()
|
||||
.parse::<sqlx::postgres::PgConnectOptions>()
|
||||
.expect("test database URL")
|
||||
} else {
|
||||
sqlx::postgres::PgConnectOptions::new()
|
||||
.host(&database.host)
|
||||
.port(database.port)
|
||||
.database(&database.database)
|
||||
.username(&database.username)
|
||||
.password(database.password.expose_secret())
|
||||
};
|
||||
let pool = sqlx::postgres::PgPoolOptions::new()
|
||||
.max_connections(1)
|
||||
.connect_with(options)
|
||||
.await
|
||||
.expect("test database connection");
|
||||
let (sources, operations, versions): (i64, i64, i64) = sqlx::query_as(
|
||||
"select
|
||||
(select count(*) from artifact_sources where workspace_id=$1),
|
||||
(select count(*) from operations where workspace_id=$1),
|
||||
(select count(*) from operation_versions v
|
||||
join operations o on o.id=v.operation_id where o.workspace_id=$1)",
|
||||
)
|
||||
.bind(workspace)
|
||||
.fetch_one(&pool)
|
||||
.await
|
||||
.expect("test storage observation");
|
||||
println!("{{\"sources\":{sources},\"operations\":{operations},\"versions\":{versions}}}");
|
||||
}
|
||||
Reference in new issue
Block a user