This commit is contained in:
parent
2e990ef462
commit
a0e293fc1a
2 changed files with 30 additions and 14 deletions
|
@ -2,7 +2,8 @@
|
|||
use super::*;
|
||||
|
||||
use anyhow::Result;
|
||||
use kxio::network::StatusCode;
|
||||
use kxio::network::{RequestBody, RequestMethod, SavedRequest, StatusCode};
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
#[tokio::test]
|
||||
async fn run_with_some_invalids() -> Result<()> {
|
||||
|
@ -28,11 +29,19 @@ async fn run_with_some_invalids() -> Result<()> {
|
|||
std::env::set_var("GITHUB_SERVER_URL", "https://git.kemitix.net");
|
||||
|
||||
//when
|
||||
run(net.into()).await?;
|
||||
let result = run(net.clone().into()).await;
|
||||
|
||||
//then
|
||||
// TODO: add check that run fails because file_1.txt is invalid
|
||||
// TODO: add check that network requests were made to get issues
|
||||
assert!(result.is_err()); // there is an invalid file
|
||||
let requests = net.requests();
|
||||
assert_eq!(
|
||||
requests,
|
||||
vec![SavedRequest::new(
|
||||
RequestMethod::Get,
|
||||
"https://git.kemitix.net/api/v1/repos/kemitix/test/issues?state=open",
|
||||
RequestBody::None,
|
||||
)]
|
||||
);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
@ -44,7 +53,7 @@ async fn run_with_no_invalids() -> Result<()> {
|
|||
net.add_get_response(
|
||||
"https://git.kemitix.net/api/v1/repos/kemitix/test/issues?state=open",
|
||||
StatusCode::OK,
|
||||
r#"[{"number": 13}]"#,
|
||||
r#"[{"number":23},{"number":43}]"#,
|
||||
);
|
||||
let _env = THE_ENVIRONMENT.lock();
|
||||
let fs = kxio::fs::temp()?;
|
||||
|
@ -57,12 +66,19 @@ async fn run_with_no_invalids() -> Result<()> {
|
|||
std::env::set_var("GITHUB_SERVER_URL", "https://git.kemitix.net");
|
||||
|
||||
//when
|
||||
|
||||
run(net.into()).await?;
|
||||
let result = run(net.clone().into()).await;
|
||||
|
||||
//then
|
||||
// TODO: add check that run fails because file_1.txt is invalid
|
||||
// TODO: add check that network requests were made to get issues
|
||||
assert!(result.is_ok()); // there is an invalid file
|
||||
let requests = net.requests();
|
||||
assert_eq!(
|
||||
requests,
|
||||
vec![SavedRequest::new(
|
||||
RequestMethod::Get,
|
||||
"https://git.kemitix.net/api/v1/repos/kemitix/test/issues?state=open",
|
||||
RequestBody::None,
|
||||
)]
|
||||
);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -38,15 +38,15 @@ fn find_markers_in_dir() -> anyhow::Result<()> {
|
|||
assert_eq!(
|
||||
markers.to_string().lines().collect::<Vec<_>>(),
|
||||
vec![
|
||||
"- Invalid: file_with_invalids.txt#2:",
|
||||
"- Invalid: file_with_invalids.txt#3:",
|
||||
" It contains a todo comment: // TODO: this is it",
|
||||
"- Invalid: file_with_invalids.txt#4:",
|
||||
"- Invalid: file_with_invalids.txt#5:",
|
||||
" It also contains a fix-me comment: // FIXME: and this is it",
|
||||
"- Closed : (3) file_with_invalids.txt#8:",
|
||||
"- Closed : (3) file_with_invalids.txt#9:",
|
||||
" We also have a todo comment: // TODO: (#3) and it has an issue number, but it is closed",
|
||||
"- Valid : (23) file_with_valids.txt#2:",
|
||||
"- Valid : (23) file_with_valids.txt#3:",
|
||||
" It also has a todo comment: // TODO: (#23) and it has an issue number",
|
||||
"- Valid : (43) file_with_valids.txt#4:",
|
||||
"- Valid : (43) file_with_valids.txt#5:",
|
||||
" Here is a fix-me comment: // FIXME: (#43) and is also has an issue number"
|
||||
]
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue