Skip to content

Commit

Permalink
[#112] FileSystem 모킹 객체 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
myyrakle committed Jul 2, 2024
1 parent d071f29 commit 7baada1
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ derive_builder = "0.10.2"
path-absolutize = "3.0.13"
whoami = "1.2.1"
thiserror = "1.0.32"
async-trait = "0.1.57"
async-trait = "0.1.80"
bytes = "1.2.1"
tokio-util = { version = "0.7.4", features = [ "codec" ] }
futures = "0.3.23"
Expand Down
7 changes: 6 additions & 1 deletion src/executor/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,19 @@ use crate::executor::predule::ExecuteResult;
use crate::logger::predule::Logger;

use super::config::global::GlobalConfig;
use super::mocking::{FileSystem, RealFileSystem};

pub struct Executor {
pub(crate) config: Arc<GlobalConfig>,
pub(crate) file_system: Arc<dyn FileSystem + Send + Sync>,
}

impl Executor {
pub fn new(config: Arc<GlobalConfig>) -> Self {
Self { config }
Self {
config,
file_system: Arc::new(RealFileSystem {}),
}
}

// 쿼리 최적화 및 실행, 결과 반환
Expand Down
15 changes: 15 additions & 0 deletions src/executor/mocking.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
use futures::io;

#[async_trait::async_trait]
pub trait FileSystem {
async fn create_dir(&self, path: &str) -> io::Result<()>;
}

pub struct RealFileSystem;

#[async_trait::async_trait]
impl FileSystem for RealFileSystem {
async fn create_dir(&self, path: &str) -> io::Result<()> {
tokio::fs::create_dir(path).await
}
}
1 change: 1 addition & 0 deletions src/executor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ pub mod encoder;
pub mod executor;
pub mod implements;
pub mod initializer;
pub mod mocking;
pub mod predule;
pub mod reduce;
pub mod result;
Expand Down

0 comments on commit 7baada1

Please sign in to comment.