mirror of
https://github.com/Hopiu/lychee.git
synced 2026-04-29 09:24:46 +00:00
Add status code in Markdown output (#677)
This commit is contained in:
parent
59ac68069b
commit
75a3da0b7e
1 changed files with 40 additions and 2 deletions
|
|
@ -73,8 +73,11 @@ impl Display for MarkdownResponseStats {
|
|||
for response in responses {
|
||||
writeln!(
|
||||
f,
|
||||
"* [{}]({}): {}",
|
||||
response.uri, response.uri, response.status
|
||||
"* [{}]({}): {} (status code: {})",
|
||||
response.uri,
|
||||
response.uri,
|
||||
response.status,
|
||||
response.status.code()
|
||||
)?;
|
||||
}
|
||||
writeln!(f)?;
|
||||
|
|
@ -102,6 +105,8 @@ impl StatsFormatter for Markdown {
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use lychee_lib::{CacheStatus, InputSource, Response, ResponseBody, Status, Uri};
|
||||
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
|
|
@ -120,4 +125,37 @@ mod tests {
|
|||
"#;
|
||||
assert_eq!(table, expected.to_string());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_render_summary() {
|
||||
let mut stats = ResponseStats::new();
|
||||
let response = Response(
|
||||
InputSource::Stdin,
|
||||
ResponseBody {
|
||||
uri: Uri::try_from("http://127.0.0.1").unwrap(),
|
||||
status: Status::Cached(CacheStatus::Error(Some(404))),
|
||||
},
|
||||
);
|
||||
stats.add(response);
|
||||
let summary = MarkdownResponseStats(stats);
|
||||
let expected = r#"## Summary
|
||||
|
||||
| Status | Count |
|
||||
|---------------|-------|
|
||||
| 🔍 Total | 1 |
|
||||
| ✅ Successful | 0 |
|
||||
| ⏳ Timeouts | 0 |
|
||||
| 🔀 Redirected | 0 |
|
||||
| 👻 Excluded | 0 |
|
||||
| ❓ Unknown | 0 |
|
||||
| 🚫 Errors | 1 |
|
||||
|
||||
|
||||
## Errors per input
|
||||
### Errors in stdin
|
||||
* [http://127.0.0.1/](http://127.0.0.1/): Cached: Error (cached) (status code: 404)
|
||||
|
||||
"#;
|
||||
assert_eq!(summary.to_string(), expected.to_string());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue