mirror of
https://github.com/Hopiu/lychee.git
synced 2026-05-05 04:14:53 +00:00
Move tests
This commit is contained in:
parent
23ba1f2e11
commit
46e30f081b
2 changed files with 52 additions and 52 deletions
|
|
@ -85,3 +85,55 @@ impl Checker {
|
|||
false
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
use std::env;
|
||||
use url::Url;
|
||||
|
||||
#[test]
|
||||
fn test_is_github() {
|
||||
let checker = Checker::try_new("foo".into()).unwrap();
|
||||
assert_eq!(
|
||||
checker
|
||||
.extract_github("https://github.com/mre/idiomatic-rust")
|
||||
.unwrap(),
|
||||
("mre".into(), "idiomatic-rust".into())
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_github() {
|
||||
let checker = Checker::try_new(env::var("GITHUB_TOKEN").unwrap()).unwrap();
|
||||
assert_eq!(
|
||||
checker.check(&Url::parse("https://github.com/mre/idiomatic-rust").unwrap()),
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_github_nonexistent() {
|
||||
let checker = Checker::try_new(env::var("GITHUB_TOKEN").unwrap()).unwrap();
|
||||
assert_eq!(
|
||||
checker.check(
|
||||
&Url::parse("https://github.com/mre/idiomatic-rust-doesnt-exist-man").unwrap()
|
||||
),
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_non_github() {
|
||||
let checker = Checker::try_new(env::var("GITHUB_TOKEN").unwrap()).unwrap();
|
||||
let valid = checker.check(&Url::parse("https://endler.dev").unwrap());
|
||||
assert_eq!(valid, true);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_non_github_nonexistent() {
|
||||
let checker = Checker::try_new(env::var("GITHUB_TOKEN").unwrap()).unwrap();
|
||||
let valid = checker.check(&Url::parse("https://endler.dev/abcd").unwrap());
|
||||
assert_eq!(valid, false);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
52
src/main.rs
52
src/main.rs
|
|
@ -45,55 +45,3 @@ fn main() -> Result<()> {
|
|||
}
|
||||
std::process::exit(errorcode)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
use std::env;
|
||||
use url::Url;
|
||||
|
||||
#[test]
|
||||
fn test_is_github() {
|
||||
let checker = Checker::try_new("foo".into()).unwrap();
|
||||
assert_eq!(
|
||||
checker
|
||||
.extract_github("https://github.com/mre/idiomatic-rust")
|
||||
.unwrap(),
|
||||
("mre".into(), "idiomatic-rust".into())
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_github() {
|
||||
let checker = Checker::try_new(env::var("GITHUB_TOKEN").unwrap()).unwrap();
|
||||
assert_eq!(
|
||||
checker.check(&Url::parse("https://github.com/mre/idiomatic-rust").unwrap()),
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_github_nonexistent() {
|
||||
let checker = Checker::try_new(env::var("GITHUB_TOKEN").unwrap()).unwrap();
|
||||
assert_eq!(
|
||||
checker.check(
|
||||
&Url::parse("https://github.com/mre/idiomatic-rust-doesnt-exist-man").unwrap()
|
||||
),
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_non_github() {
|
||||
let checker = Checker::try_new(env::var("GITHUB_TOKEN").unwrap()).unwrap();
|
||||
let valid = checker.check(&Url::parse("https://endler.dev").unwrap());
|
||||
assert_eq!(valid, true);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_non_github_nonexistent() {
|
||||
let checker = Checker::try_new(env::var("GITHUB_TOKEN").unwrap()).unwrap();
|
||||
let valid = checker.check(&Url::parse("https://endler.dev/abcd").unwrap());
|
||||
assert_eq!(valid, false);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue