Skip to content

Commit

Permalink
test: add TestEnv::new
Browse files Browse the repository at this point in the history
  • Loading branch information
evenyag committed Jul 31, 2023
1 parent 9d7f9f9 commit 7704fdd
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 14 deletions.
13 changes: 4 additions & 9 deletions src/mito2/src/engine/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use crate::test_util::{CreateRequestBuilder, TestEnv};

#[tokio::test]
async fn test_engine_new_stop() {
let env = TestEnv::new("engine-stop");
let env = TestEnv::with_prefix("engine-stop");
let engine = env.create_engine(MitoConfig::default()).await;

engine.stop().await.unwrap();
Expand All @@ -37,7 +37,7 @@ async fn test_engine_new_stop() {

#[tokio::test]
async fn test_engine_create_new_region() {
let env = TestEnv::new("new-region");
let env = TestEnv::with_prefix("new-region");
let engine = env.create_engine(MitoConfig::default()).await;

let region_id = RegionId::new(1, 1);
Expand All @@ -49,7 +49,7 @@ async fn test_engine_create_new_region() {

#[tokio::test]
async fn test_engine_create_region_if_not_exists() {
let env = TestEnv::new("create-not-exists");
let env = TestEnv::with_prefix("create-not-exists");
let engine = env.create_engine(MitoConfig::default()).await;

let builder = CreateRequestBuilder::new(RegionId::new(1, 1)).create_if_not_exists(true);
Expand All @@ -61,7 +61,7 @@ async fn test_engine_create_region_if_not_exists() {

#[tokio::test]
async fn test_engine_create_existing_region() {
let env = TestEnv::new("create-existing");
let env = TestEnv::with_prefix("create-existing");
let engine = env.create_engine(MitoConfig::default()).await;

let builder = CreateRequestBuilder::new(RegionId::new(1, 1));
Expand All @@ -74,8 +74,3 @@ async fn test_engine_create_existing_region() {
"unexpected err: {err}"
);
}

#[tokio::test]
async fn test_engine_open_empty() {
let env = TestEnv::new("open-empty");
}
6 changes: 3 additions & 3 deletions src/mito2/src/manifest/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ mod test {
#[tokio::test]
async fn create_manifest_manager() {
let metadata = Arc::new(basic_region_metadata());
let env = TestEnv::new("");
let env = TestEnv::new();
let manager = env
.create_manifest_manager(CompressionType::Uncompressed, 10, Some(metadata.clone()))
.await
Expand All @@ -389,7 +389,7 @@ mod test {

#[tokio::test]
async fn open_manifest_manager() {
let env = TestEnv::new("");
let env = TestEnv::new();
// Try to opens an empty manifest.
assert!(env
.create_manifest_manager(CompressionType::Uncompressed, 10, None)
Expand Down Expand Up @@ -420,7 +420,7 @@ mod test {
#[tokio::test]
async fn region_change_add_column() {
let metadata = Arc::new(basic_region_metadata());
let env = TestEnv::new("");
let env = TestEnv::new();
let manager = env
.create_manifest_manager(CompressionType::Uncompressed, 10, Some(metadata.clone()))
.await
Expand Down
9 changes: 8 additions & 1 deletion src/mito2/src/test_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,15 @@ pub struct TestEnv {
}

impl TestEnv {
/// Returns a new env with empty prefix for test.
pub fn new() -> TestEnv {
TestEnv {
data_home: create_temp_dir(""),
}
}

/// Returns a new env with specific `prefix` for test.
pub fn new(prefix: &str) -> TestEnv {
pub fn with_prefix(prefix: &str) -> TestEnv {
TestEnv {
data_home: create_temp_dir(prefix),
}
Expand Down
2 changes: 1 addition & 1 deletion src/mito2/src/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ mod tests {

#[tokio::test]
async fn test_worker_group_start_stop() {
let env = TestEnv::new("group-stop");
let env = TestEnv::with_prefix("group-stop");
let group = env
.create_worker_group(MitoConfig {
num_workers: 4,
Expand Down

0 comments on commit 7704fdd

Please sign in to comment.