feat(tests): day4 tests

Signed-off-by: Alex Chi <iskyzh@gmail.com>
This commit is contained in:
Alex Chi
2022-12-24 18:12:57 -05:00
parent 51e075c1ed
commit 7a571a7c7d
7 changed files with 19 additions and 5 deletions

View File

@@ -4,3 +4,6 @@ pub mod lsm_iterator;
pub mod lsm_storage; pub mod lsm_storage;
pub mod mem_table; pub mod mem_table;
pub mod table; pub mod table;
#[cfg(test)]
mod tests;

View File

@@ -39,7 +39,7 @@ pub struct LsmStorage {
} }
impl LsmStorage { impl LsmStorage {
pub fn open(_path: &Path) -> Result<Self> { pub fn open(path: impl AsRef<Path>) -> Result<Self> {
Ok(Self { Ok(Self {
inner: ArcSwap::from_pointee(LsmStorageInner::create()), inner: ArcSwap::from_pointee(LsmStorageInner::create()),
}) })
@@ -49,17 +49,17 @@ impl LsmStorage {
unimplemented!() unimplemented!()
} }
pub fn put(&mut self, key: &[u8], value: &[u8]) -> Result<()> { pub fn put(&self, key: &[u8], value: &[u8]) -> Result<()> {
assert!(!value.is_empty(), "value cannot be empty"); assert!(!value.is_empty(), "value cannot be empty");
assert!(!key.is_empty(), "key cannot be empty"); assert!(!key.is_empty(), "key cannot be empty");
unimplemented!() unimplemented!()
} }
pub fn delete(&mut self, _key: &[u8]) -> Result<()> { pub fn delete(&self, _key: &[u8]) -> Result<()> {
unimplemented!() unimplemented!()
} }
pub fn sync(&mut self) -> Result<()> { pub fn sync(&self) -> Result<()> {
unimplemented!() unimplemented!()
} }

View File

@@ -0,0 +1 @@
pub mod day4_tests;

View File

@@ -0,0 +1 @@
//! Please copy `mini-lsm/src/tests/day4_tests.rs` here so that you can run tests.

View File

@@ -1 +1 @@
pub mod day3_tests; pub mod day4_tests;

View File

@@ -10,6 +10,7 @@ enum CopyTestAction {
Day1, Day1,
Day2, Day2,
Day3, Day3,
Day4,
} }
#[derive(clap::Subcommand, Debug)] #[derive(clap::Subcommand, Debug)]
@@ -168,6 +169,14 @@ fn copy_test_case(test: CopyTestAction) -> Result<()> {
) )
.run()?; .run()?;
} }
CopyTestAction::Day4 => {
cmd!(
"cp",
"mini-lsm/src/tests/day4_tests.rs",
"mini-lsm-starter/src/tests/day4_tests.rs"
)
.run()?;
}
} }
Ok(()) Ok(())
} }