[query/datasource] add database unit tests
#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
async fn test_datasource() -> anyhow::Result<()> {
+ use common_planners::*;
use pretty_assertions::assert_eq;
+ use crate::datasources::IDataSource;
use crate::datasources::*;
let datasource = DataSource::try_create()?;
@@ -17,5 +19,35 @@ async fn test_datasource() -> anyhow::Result<()> {
let actual = format!("{}", e);
assert_eq!(expect, actual);
}
+
+ // Database tests.
+ {
+ // Create database.
+ datasource
+ .create_database(CreateDatabasePlan {
+ if_not_exists: false,
+ db: "test_db".to_string(),
+ engine: DatabaseEngineType::Local,
+ options: Default::default()
+ })
+ .await?;
+
+ // Check
+ let result = datasource.get_database("test_db");
+ assert_eq!(true, result.is_ok());
+
+ // Drop database.
+ datasource
+ .drop_database(DropDatabasePlan {
+ if_not_exists: false,
+ db: "test_db".to_string()
+ })
+ .await?;
+
+ // Check.
+ let result = datasource.get_database("test_db");
+ assert_eq!(true, result.is_err());
+ }
+
Ok(())
}
