Skip to content

Commit

Permalink
fix: setup tests
Browse files Browse the repository at this point in the history
  • Loading branch information
veeso committed Oct 22, 2024
1 parent f51a415 commit a9d5b90
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 1 deletion.
3 changes: 3 additions & 0 deletions remotefs-fuse/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ env_logger = "^0.11"
pretty_assertions = "^1"
remotefs-memory = "0.1"

[target.'cfg(target_family = "unix")'.dev-dependencies]
nix = { version = "0.29", features = ["user"] }

[features]
default = []
no-log = ["log/max_level_off"]
Expand Down
6 changes: 6 additions & 0 deletions remotefs-fuse/src/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ pub struct Driver {
remote: Box<dyn RemoteFs>,
}

impl From<Box<dyn RemoteFs>> for Driver {
fn from(remote: Box<dyn RemoteFs>) -> Self {
Self::new(remote)
}
}

impl Driver {
/// Create a new instance of the [`Driver`] providing a instance which implements the [`RemoteFs`] trait.
///
Expand Down
2 changes: 2 additions & 0 deletions remotefs-fuse/src/driver/unix.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
mod file_handle;
mod inode;
#[cfg(test)]
mod test;

use std::ffi::OsStr;
use std::fs;
Expand Down
25 changes: 25 additions & 0 deletions remotefs-fuse/src/driver/unix/test.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
use std::path::PathBuf;

use remotefs::fs::UnixPex;
use remotefs::RemoteFs;
use remotefs_memory::{node, Inode, MemoryFs, Node, Tree};

use crate::Driver;

fn setup_driver() -> Driver {
let gid = nix::unistd::getgid().as_raw();
let uid = nix::unistd::getuid().as_raw();

let tree = Tree::new(node!(
PathBuf::from("/"),
Inode::dir(uid, gid, UnixPex::from(0o755)),
));

let fs = MemoryFs::new(tree)
.with_get_gid(|| nix::unistd::getgid().as_raw())
.with_get_uid(|| nix::unistd::getuid().as_raw());

let fs = Box::new(fs) as Box<dyn RemoteFs>;

Driver::from(fs)
}
17 changes: 16 additions & 1 deletion remotefs-fuse/tests/driver/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
use remotefs_fuse::Driver;

use std::path::PathBuf;

use remotefs::fs::UnixPex;
use remotefs::RemoteFs;
use remotefs_memory::{node, Inode, MemoryFs, Node, Tree};

pub fn setup_driver() -> Driver {
todo!();
let tree = Tree::new(node!(
PathBuf::from("/"),
Inode::dir(0, 0, UnixPex::from(0o755)),
));

let fs = MemoryFs::new(tree);

let fs = Box::new(fs) as Box<dyn RemoteFs>;

Driver::from(fs)
}

0 comments on commit a9d5b90

Please sign in to comment.