Skip to content

Commit 6be6433

Browse files
committed
[test] apply the new test style to common-meta-sled-store
Signed-off-by: Chojan Shang <[email protected]>
1 parent 654a458 commit 6be6433

File tree

7 files changed

+26
-11
lines changed

7 files changed

+26
-11
lines changed

common/meta/sled-store/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ license = "Apache-2.0"
77
publish = false
88
edition = "2021"
99

10+
[lib]
11+
doctest = false
12+
test = false
1013

1114
[dependencies]
1215
common-exception = {path = "../../exception"}

common/meta/sled-store/src/lib.rs

-5
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,3 @@ mod db;
3131
mod sled_key_space;
3232
mod sled_serde;
3333
mod sled_tree;
34-
35-
#[cfg(test)]
36-
mod sled_tree_test;
37-
#[cfg(test)]
38-
mod testing;
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2021 Datafuse Labs.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
mod sled_tree;
16+
mod testing;

common/meta/sled-store/src/sled_tree_test.rs renamed to common/meta/sled-store/tests/it/sled_tree.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,14 @@ use async_raft::raft::EntryNormal;
1717
use async_raft::raft::EntryPayload;
1818
use common_base::tokio;
1919
use common_base::GlobalSequence;
20+
use common_meta_sled_store::get_sled_db;
21+
use common_meta_sled_store::SledTree;
2022
use common_meta_types::Cmd;
2123
use common_meta_types::LogEntry;
2224
use common_meta_types::LogId;
2325
use common_meta_types::LogIndex;
2426
use common_meta_types::SeqV;
2527

26-
use crate::get_sled_db;
2728
use crate::testing::fake_key_spaces::Files;
2829
use crate::testing::fake_key_spaces::GenericKV;
2930
use crate::testing::fake_key_spaces::Logs;
@@ -32,7 +33,6 @@ use crate::testing::fake_key_spaces::StateMachineMeta;
3233
use crate::testing::fake_state_machine_meta::StateMachineMetaKey::Initialized;
3334
use crate::testing::fake_state_machine_meta::StateMachineMetaKey::LastApplied;
3435
use crate::testing::fake_state_machine_meta::StateMachineMetaValue;
35-
use crate::SledTree;
3636

3737
/// 1. Open a temp sled::Db for all tests.
3838
/// 2. Initialize a global tracing.
@@ -41,8 +41,8 @@ use crate::SledTree;
4141
macro_rules! init_sled_ut {
4242
() => {{
4343
let t = tempfile::tempdir().expect("create temp dir to sled db");
44-
$crate::init_temp_sled_db(t);
4544

45+
common_meta_sled_store::init_temp_sled_db(t);
4646
common_tracing::init_default_ut_tracing();
4747

4848
let name = common_tracing::func_name!();

common/meta/sled-store/src/testing/fake_key_spaces.rs renamed to common/meta/sled-store/tests/it/testing/fake_key_spaces.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
// limitations under the License.
1414

1515
use async_raft::raft::Entry;
16+
use common_meta_sled_store::SledKeySpace;
1617
use common_meta_types::LogEntry;
1718
use common_meta_types::LogIndex;
1819
use common_meta_types::Node;
@@ -21,10 +22,10 @@ use common_meta_types::SeqV;
2122

2223
use crate::testing::fake_state_machine_meta::StateMachineMetaKey;
2324
use crate::testing::fake_state_machine_meta::StateMachineMetaValue;
24-
use crate::SledKeySpace;
2525

2626
/// Types for raft log in SledTree
2727
pub struct Logs {}
28+
2829
impl SledKeySpace for Logs {
2930
const PREFIX: u8 = 1;
3031
const NAME: &'static str = "log";

common/meta/sled-store/src/testing/fake_state_machine_meta.rs renamed to common/meta/sled-store/tests/it/testing/fake_state_machine_meta.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,17 @@
1111
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
14+
1415
use std::fmt;
1516

1617
use async_raft::raft::MembershipConfig;
1718
use async_raft::LogId;
1819
use common_exception::ErrorCode;
20+
use common_meta_sled_store::SledOrderedSerde;
1921
use serde::Deserialize;
2022
use serde::Serialize;
2123
use sled::IVec;
2224

23-
use crate::SledOrderedSerde;
24-
2525
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
2626
pub enum StateMachineMetaKey {
2727
/// The last applied log id in the state machine.

0 commit comments

Comments
 (0)