refactor: replace Ctx::new with Ctx::From<PathBuf>
Some checks failed
Test / build (map[name:nightly]) (push) Failing after 1m3s
Test / build (map[name:stable]) (push) Failing after 38s

This commit is contained in:
Paul Campbell 2024-12-15 17:55:23 +00:00
parent 1c82ed3a80
commit ee46d64c07
3 changed files with 15 additions and 3 deletions

View file

@ -67,8 +67,8 @@ pub struct Ctx {
pub net: Net, pub net: Net,
pub prt: Printer, pub prt: Printer,
} }
impl Ctx { impl From<PathBuf> for Ctx {
pub fn new(base: impl Into<PathBuf>) -> Self { fn from(base: PathBuf) -> Self {
Self { Self {
fs: kxio::fs::new(base), fs: kxio::fs::new(base),
net: kxio::net::new(), net: kxio::net::new(),

View file

@ -6,5 +6,5 @@ use trello_to_deck::{run, Ctx};
#[tokio::main] #[tokio::main]
#[cfg_attr(test, mutants::skip)] #[cfg_attr(test, mutants::skip)]
async fn main() -> Result<()> { async fn main() -> Result<()> {
run(Ctx::new(std::env::current_dir()?)).await run(Ctx::from(std::env::current_dir()?)).await
} }

View file

@ -15,3 +15,15 @@ mod config;
pub(crate) mod given; pub(crate) mod given;
mod init; mod init;
mod template; mod template;
#[test]
fn ctx_from_pathbuf() {
//given
let pathbuf = std::path::PathBuf::from("test");
//when
let ctx = Ctx::from(pathbuf.clone());
//then
assert_peq!(ctx.fs.base(), pathbuf);
}