From 5d50f446a1a4612c0c931bdbc61f945760392f29 Mon Sep 17 00:00:00 2001 From: fxqnlr Date: Fri, 4 Nov 2022 23:41:21 +0100 Subject: "finished" update, added some tests --- src/input.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/input.rs') diff --git a/src/input.rs b/src/input.rs index 0c13e67..e0c9ae9 100644 --- a/src/input.rs +++ b/src/input.rs @@ -1,6 +1,7 @@ use std::io::{stdin, Error, ErrorKind}; use crate::{config::Cfg, list, modification, update}; +#[derive(Debug, PartialEq, Eq)] pub struct Input { pub command: String, pub args: Option>, @@ -27,8 +28,6 @@ impl Input { }, _ => { panic!("This should never happen") } } - - } } @@ -53,3 +52,10 @@ pub async fn get_input(config: Cfg) -> Result<(), Box> { _ => Err(Box::new(Error::new(ErrorKind::InvalidInput, "UNKNOWN_COMMAND"))), } } + +#[test] +fn input_from() { + let string = String::from("list add test 1.19.2 fabric"); + let input = Input { command: String::from("list"), args: Some(vec![String::from("add"), String::from("test"), String::from("1.19.2"), String::from("fabric")]) }; + assert_eq!(Input::from(string).unwrap(), input); +} -- cgit v1.2.3