refactor: replace Ctx::new with Ctx::From<PathBuf>
This commit is contained in:
parent
1c82ed3a80
commit
d511c98e47
3 changed files with 15 additions and 3 deletions
|
@ -67,8 +67,8 @@ pub struct Ctx {
|
|||
pub net: Net,
|
||||
pub prt: Printer,
|
||||
}
|
||||
impl Ctx {
|
||||
pub fn new(base: impl Into<PathBuf>) -> Self {
|
||||
impl From<PathBuf> for Ctx {
|
||||
fn from(base: PathBuf) -> Self {
|
||||
Self {
|
||||
fs: kxio::fs::new(base),
|
||||
net: kxio::net::new(),
|
||||
|
|
|
@ -6,5 +6,5 @@ use trello_to_deck::{run, Ctx};
|
|||
#[tokio::main]
|
||||
#[cfg_attr(test, mutants::skip)]
|
||||
async fn main() -> Result<()> {
|
||||
run(Ctx::new(std::env::current_dir()?)).await
|
||||
run(Ctx::from(std::env::current_dir()?)).await
|
||||
}
|
||||
|
|
|
@ -15,3 +15,15 @@ mod config;
|
|||
pub(crate) mod given;
|
||||
mod init;
|
||||
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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue