mirror of
https://github.com/Skallwar/suckit.git
synced 2026-09-10 07:16:19 -04:00
tests: Add pretty_assertions crate and example.com test
This commit is contained in:
parent
58f5710cb8
commit
a6bd14a323
1665
Cargo.lock
generated
Normal file
1665
Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -7,6 +7,7 @@ edition = "2018"
|
|||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
structopt = { version = "0.3" }
|
||||
structopt = "0.3"
|
||||
reqwest = "0.9.22"
|
||||
regex = "1"
|
||||
pretty_assertions = "0.6.1"
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@ pub fn download_url(url: Url) -> Result<String, reqwest::Error> {
|
|||
mod tests {
|
||||
use super::*;
|
||||
|
||||
use pretty_assertions::{assert_eq, assert_ne};
|
||||
|
||||
#[test]
|
||||
fn test_download_url() {
|
||||
let url: Url = Url::parse("https://lwn.net").unwrap();
|
||||
|
|
@ -18,4 +20,58 @@ mod tests {
|
|||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_url_content() {
|
||||
let url: Url = Url::parse("https://example.com").unwrap();
|
||||
match download_url(url) {
|
||||
Err(e) => assert!(false, "Fail to download lwn.net: {:?}", e),
|
||||
Ok(content) => assert_eq!(content, "<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Example Domain</title>
|
||||
|
||||
<meta charset=\"utf-8\" />
|
||||
<meta http-equiv=\"Content-type\" content=\"text/html; charset=utf-8\" />
|
||||
<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />
|
||||
<style type=\"text/css\">
|
||||
body {
|
||||
background-color: #f0f0f2;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-family: -apple-system, system-ui, BlinkMacSystemFont, \"Segoe UI\", \"Open Sans\", \"Helvetica Neue\", Helvetica, Arial, sans-serif;
|
||||
|
||||
}
|
||||
div {
|
||||
width: 600px;
|
||||
margin: 5em auto;
|
||||
padding: 2em;
|
||||
background-color: #fdfdff;
|
||||
border-radius: 0.5em;
|
||||
box-shadow: 2px 3px 7px 2px rgba(0,0,0,0.02);
|
||||
}
|
||||
a:link, a:visited {
|
||||
color: #38488f;
|
||||
text-decoration: none;
|
||||
}
|
||||
@media (max-width: 700px) {
|
||||
div {
|
||||
margin: 0 auto;
|
||||
width: auto;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div>
|
||||
<h1>Example Domain</h1>
|
||||
<p>This domain is for use in illustrative examples in documents. You may use this
|
||||
domain in literature without prior coordination or asking for permission.</p>
|
||||
<p><a href=\"https://www.iana.org/domains/example\">More information...</a></p>
|
||||
</div>
|
||||
</body>
|
||||
</html>\n"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue