Skip to content

Commit

Permalink
[#112] mockall 추가 및 리팩토링, init 테스트코드 작성
Browse files Browse the repository at this point in the history
  • Loading branch information
myyrakle authored and DPS0340 committed Jul 6, 2024
1 parent 8027c02 commit 7e521c1
Show file tree
Hide file tree
Showing 6 changed files with 359 additions and 29 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ colored = "2.0.0"
uuid = "1.1.2"
itertools = "0.10.5"
anyhow = "1.0.86"
mockall = "0.12.1"

[target.'cfg(windows)'.dependencies]
winreg = "0.10.1"
Expand Down
16 changes: 16 additions & 0 deletions src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,19 @@ pub const DEFAULT_CONFIG_BASEPATH: &str = r"C:\Program Files\rrdb";
pub const DEFAULT_CONFIG_BASEPATH: &str = "/var/lib/rrdb";

pub const LAUNCHD_PLIST_PATH: &str = "/Library/LaunchDaemons/io.github.myyrakle.rrdb.plist";

#[cfg(target_os = "linux")]
pub const SYSTEMD_DAEMON_SCRIPT: &str = r#"[Unit]
Description=RRDB
[Service]
Type=simple
Restart=on-failure
ExecStart=/usr/bin/rrdb run
RemainAfterExit=on
User=root
StandardOutput=file:/var/log/rrdb.stdout.log
StandardError=file:/var/log/rrdb.stderr.log
[Install]
WantedBy=multi-user.target"#;
4 changes: 3 additions & 1 deletion src/executor/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,20 @@ use crate::executor::predule::ExecuteResult;
use crate::logger::predule::Logger;

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

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

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

Expand Down
Loading

0 comments on commit 7e521c1

Please sign in to comment.