Skip to content

Commit

Permalink
Moving sql test on core to EXPLAIN
Browse files Browse the repository at this point in the history
  • Loading branch information
mamcx committed Jan 30, 2025
1 parent c592668 commit 46082fa
Show file tree
Hide file tree
Showing 3 changed files with 329 additions and 338 deletions.
19 changes: 19 additions & 0 deletions crates/core/src/db/relational_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1314,10 +1314,15 @@ fn default_row_count_fn(db: Identity) -> RowCountFn {
#[cfg(any(test, feature = "test"))]
pub mod tests_utils {
use super::*;
use crate::sql::ast::{SchemaViewer, TableSchemaView};
use core::ops::Deref;
use durability::EmptyHistory;
use expect_test::Expect;
use spacetimedb_lib::identity::AuthCtx;
use spacetimedb_lib::{bsatn::to_vec, ser::Serialize};
use spacetimedb_paths::FromPathUnchecked;
use spacetimedb_physical_plan::plan::tests_utils::*;
use spacetimedb_physical_plan::printer::ExplainOptions;
use tempfile::TempDir;

/// A [`RelationalDB`] in a temporary directory.
Expand Down Expand Up @@ -1605,6 +1610,20 @@ pub mod tests_utils {
Self(log)
}
}

pub fn expect_query<T: TableSchemaView + StateView>(tx: &T, sql: &str, expect: Expect) {
let auth = AuthCtx::for_testing();
let schema = SchemaViewer::new(tx, &auth);

check_query(&schema, ExplainOptions::default(), sql, expect)
}

pub fn expect_sub<T: TableSchemaView + StateView>(tx: &T, sql: &str, expect: Expect) {
let auth = AuthCtx::for_testing();
let schema = SchemaViewer::new(tx, &auth);

check_sub(&schema, ExplainOptions::default(), sql, expect)
}
}

#[cfg(test)]
Expand Down
Loading

0 comments on commit 46082fa

Please sign in to comment.