This commit is contained in:
parent
a0e293fc1a
commit
926b90c37f
3 changed files with 22 additions and 3 deletions
|
@ -17,3 +17,4 @@ serde_json = "1.0"
|
|||
[dev-dependencies]
|
||||
assert2 = "0.3"
|
||||
pretty_assertions = "1.4"
|
||||
rstest = "0.22"
|
||||
|
|
|
@ -12,5 +12,5 @@ pub fn marker_pattern() -> Result<Regex> {
|
|||
|
||||
/// The pattern to find an issue number on an already found TODO or FIXME comment
|
||||
pub fn issue_pattern() -> Result<Regex> {
|
||||
regex::Regex::new(r"( |)(\(|\(#)(?P<ISSUE_NUMBER>\d+)(\))").context("issue regex")
|
||||
regex::Regex::new(r"\(#?(?P<ISSUE_NUMBER>\d+)\)").context("issue regex")
|
||||
}
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
use anyhow::Result;
|
||||
|
||||
//
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn when_issue_should_find_number() -> anyhow::Result<()> {
|
||||
fn when_issue_should_find_number() -> Result<()> {
|
||||
//given
|
||||
let line = " a line with a // TODO: (#13) issue number";
|
||||
|
||||
|
@ -18,8 +20,24 @@ fn when_issue_should_find_number() -> anyhow::Result<()> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[rstest::rstest]
|
||||
#[case("(#13)")]
|
||||
#[case("(13)")]
|
||||
fn find_issue_thirteen(#[case] input: &str) -> Result<()> {
|
||||
assert_eq!(
|
||||
issue_pattern()?
|
||||
.captures(input)
|
||||
.unwrap()
|
||||
.name("ISSUE_NUMBER")
|
||||
.unwrap()
|
||||
.as_str(),
|
||||
"13"
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn when_no_issue_should_find_nothing() -> anyhow::Result<()> {
|
||||
fn when_no_issue_should_find_nothing() -> Result<()> {
|
||||
//given
|
||||
let line = " a line with a // TODO: and no issue number";
|
||||
|
||||
|
|
Loading…
Reference in a new issue