Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests to the user API #2

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/cli.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
use clap::{Parser, Subcommand};

#[derive(Parser)]
#[derive(Debug, PartialEq, Parser)]
#[command(author, version, about, long_about = None)]
#[command(propagate_version = true)]
pub struct Cli {
#[command(subcommand)]
pub command: RodoCommands,
}

#[derive(Subcommand)]
#[derive(Debug, PartialEq, Subcommand)]
pub enum RodoCommands {
/// Catalog all the TODOs in a given folder. The default value is the current directory.
Catalog { opt_filepath: Option<String> },
Expand Down
17 changes: 17 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,20 @@ fn main() {
}
}
}

#[test]
fn test_list () {
let cli = Cli::parse_from(vec!["", "list", "."]);
assert_eq!(cli, Cli{ command: RodoCommands::List {opt_filepath: Some(String::from("."))}});

let cli = Cli::parse_from(vec!["", "list"]);
assert_eq!(cli, Cli{ command: RodoCommands::List {opt_filepath: None}});
}

#[test]
fn test_catalog () {
let cli = Cli::parse_from(vec!["", "catalog", "."]);
assert_eq!(cli, Cli{ command: RodoCommands::Catalog {opt_filepath: Some(String::from("."))}});
let cli = Cli::parse_from(vec!["", "catalog"]);
assert_eq!(cli, Cli{ command: RodoCommands::Catalog {opt_filepath: None}});
}
Loading