This commit is contained in:
parent
92811bc074
commit
64ddc6a6e6
4 changed files with 89 additions and 6 deletions
|
@ -20,12 +20,12 @@ impl Config {
|
|||
pub fn repo(&self) -> &str {
|
||||
&self.repo
|
||||
}
|
||||
pub fn server(&self) -> &str {
|
||||
&self.server
|
||||
}
|
||||
pub fn auth_token(&self) -> Option<&str> {
|
||||
self.auth_token.as_deref()
|
||||
}
|
||||
// pub fn server(&self) -> &str {
|
||||
// &self.server
|
||||
// }
|
||||
// pub fn auth_token(&self) -> Option<&str> {
|
||||
// self.auth_token.as_deref()
|
||||
// }
|
||||
pub fn prefix_pattern(&self) -> &Regex {
|
||||
&self.prefix_pattern
|
||||
}
|
||||
|
|
|
@ -3,6 +3,9 @@ mod config;
|
|||
mod line;
|
||||
mod markers;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
pub use config::Config;
|
||||
pub use line::Line;
|
||||
pub use markers::FoundMarkers;
|
||||
|
|
76
src/model/tests/config.rs
Normal file
76
src/model/tests/config.rs
Normal file
|
@ -0,0 +1,76 @@
|
|||
use anyhow::Result;
|
||||
|
||||
use crate::patterns::{issue_pattern, marker_pattern};
|
||||
|
||||
//
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn with_config_get_fs() -> Result<()> {
|
||||
//given
|
||||
let fs = kxio::fs::temp()?;
|
||||
let config = a_config(fs.clone())?;
|
||||
|
||||
//when
|
||||
let result = config.fs();
|
||||
|
||||
//then
|
||||
assert_eq!(result.base(), fs.base());
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn with_config_get_prefix_pattern() -> Result<()> {
|
||||
//given
|
||||
let fs = kxio::fs::temp()?;
|
||||
let config = a_config(fs)?;
|
||||
|
||||
//when
|
||||
let result = config.prefix_pattern();
|
||||
|
||||
//then
|
||||
assert_eq!(result.to_string(), marker_pattern()?.to_string());
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn with_config_get_issue_pattern() -> Result<()> {
|
||||
//given
|
||||
let fs = kxio::fs::temp()?;
|
||||
let config = a_config(fs)?;
|
||||
|
||||
//when
|
||||
let result = config.issue_pattern();
|
||||
|
||||
//then
|
||||
assert_eq!(result.to_string(), issue_pattern()?.to_string());
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn with_config_get_repo() -> Result<()> {
|
||||
//given
|
||||
let fs = kxio::fs::temp()?;
|
||||
let config = a_config(fs)?;
|
||||
|
||||
//when
|
||||
let result = config.repo();
|
||||
|
||||
//then
|
||||
assert_eq!(result, "kemitix/test");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn a_config(fs: kxio::fs::FileSystem) -> Result<Config> {
|
||||
Ok(Config::builder()
|
||||
.fs(fs)
|
||||
.server("https://git.kemitix.net".to_string())
|
||||
.repo("kemitix/test".to_string())
|
||||
.prefix_pattern(marker_pattern()?)
|
||||
.issue_pattern(issue_pattern()?)
|
||||
.build())
|
||||
}
|
4
src/model/tests/mod.rs
Normal file
4
src/model/tests/mod.rs
Normal file
|
@ -0,0 +1,4 @@
|
|||
//
|
||||
use super::*;
|
||||
|
||||
mod config;
|
Loading…
Reference in a new issue