Skip to content

Commit b4175be

Browse files
committed
Tests: change port from 8084 to 28382
Change the port 8084, which seems to have issues (HTTP error 400) on Github Ubuntu runner. Choose an arbitrary high range port, separated from ports used elsewhere in the tests. Some day it might be nice to have a method to find an appropriate port automatically, or to overhaul the HTTP server used in testing, or implement integration tests based on tokio or something along those lines. Currently the tests are a bit fragile, although, that said they have done reasonably well so far.
1 parent 0084c12 commit b4175be

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

src/message.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ mod tests {
442442

443443
fn serve_html() {
444444
let _ = thread::spawn(move || {
445-
let srv = tiny_http::Server::http("127.0.0.1:8084").unwrap();
445+
let srv = tiny_http::Server::http("127.0.0.1:28382").unwrap();
446446
loop {
447447
let rq = srv.recv().unwrap();
448448
let resp = match rq.url() {
@@ -468,7 +468,7 @@ mod tests {
468468

469469
fn pt_n(n: usize) -> Vec<TitleResp> {
470470
let mut c = 0;
471-
let m = iter::repeat("http://127.0.0.1:8084/")
471+
let m = iter::repeat("http://127.0.0.1:28382/")
472472
.take(n)
473473
.map(|t| {c += 1; format!("{}{}", t, c)})
474474
.collect::<Vec<String>>()
@@ -480,16 +480,16 @@ mod tests {
480480
fn test_process_titles_count() {
481481
serve_html();
482482
assert_eq!(0, pt("").len());
483-
assert_eq!(1, pt("http://127.0.0.1:8084/").len());
484-
assert_eq!(2, pt("http://127.0.0.1:8084/1 http://127.0.0.1:8084/2").len());
483+
assert_eq!(1, pt("http://127.0.0.1:28382/").len());
484+
assert_eq!(2, pt("http://127.0.0.1:28382/1 http://127.0.0.1:28382/2").len());
485485
assert_eq!(4, pt_n(4).len());
486486
assert_eq!(8, pt_n(8).len());
487487
}
488488

489489
#[test]
490490
fn test_process_titles_deduplicate() {
491-
assert_eq!(1, pt("http://127.0.0.1:8084 http://127.0.0.1:8084").len());
492-
let m = iter::repeat("http://127.0.0.1:8084/")
491+
assert_eq!(1, pt("http://127.0.0.1:28382 http://127.0.0.1:28382").len());
492+
let m = iter::repeat("http://127.0.0.1:28382/")
493493
.take(10)
494494
.collect::<Vec<&str>>()
495495
.join(" ");
@@ -507,7 +507,7 @@ mod tests {
507507

508508
#[test]
509509
fn test_process_titles_value() {
510-
pt("http://127.0.0.1:8084/")
510+
pt("http://127.0.0.1:28382/")
511511
.iter()
512512
.for_each(|v| assert_eq!(&TITLE("⤷ |t|".to_string()), v));
513513
}
@@ -518,7 +518,7 @@ mod tests {
518518
feat!(rtd, history) = true;
519519
feat!(rtd, cross_channel_history) = false;
520520

521-
let msg = Msg::new(&rtd, "testnick", "#test", "http://127.0.0.1:8084/");
521+
let msg = Msg::new(&rtd, "testnick", "#test", "http://127.0.0.1:28382/");
522522
let db = Database::open_in_memory().unwrap();
523523

524524
let d = r#"( [[:alpha:]]{3}){2} \d{1,2} \d{2}:\d{2}:\d{2} \d{4}"#;
@@ -566,7 +566,7 @@ mod tests {
566566

567567
feat!(rtd, mask_highlights) = false;
568568

569-
let msg2 = Msg::new(&rtd, "testnick", "#test2", "http://127.0.0.1:8084/");
569+
let msg2 = Msg::new(&rtd, "testnick", "#test2", "http://127.0.0.1:28382/");
570570

571571
// cross-posted history is disabled
572572
let res: Vec<_> = process_titles(&rtd, &db, &msg2).collect();
@@ -597,14 +597,14 @@ mod tests {
597597

598598
#[test]
599599
fn test_process_titles_http_https_only() {
600-
assert_eq!(0, pt("git://127.0.0.1:8084/").len());
601-
assert_eq!(0, pt("ssh://127.0.0.1:8084/").len());
602-
assert_eq!(0, pt("ftp://127.0.0.1:8084/").len());
600+
assert_eq!(0, pt("git://127.0.0.1:28382/").len());
601+
assert_eq!(0, pt("ssh://127.0.0.1:28382/").len());
602+
assert_eq!(0, pt("ftp://127.0.0.1:28382/").len());
603603
}
604604

605605
#[test]
606606
fn test_process_titles_unsafe_chars() {
607-
assert_eq!(0, pt("http://127.0.0.1:8084/{}").len());
607+
assert_eq!(0, pt("http://127.0.0.1:28382/{}").len());
608608
}
609609

610610
fn err_val(r: &TitleResp, s: &str) -> bool {
@@ -615,10 +615,10 @@ mod tests {
615615

616616
#[test]
617617
fn test_process_titles_resolve_error() {
618-
assert!(err_val(&pt("http://127.0.0.1:8084/empty")[0],
619-
"http://127.0.0.1:8084/empty: failed to parse title"));
620-
assert!(err_val(&pt("http://127.0.0.1:8084/blank")[0],
621-
"http://127.0.0.1:8084/blank: failed to parse title"));
618+
assert!(err_val(&pt("http://127.0.0.1:28382/empty")[0],
619+
"http://127.0.0.1:28382/empty: failed to parse title"));
620+
assert!(err_val(&pt("http://127.0.0.1:28382/blank")[0],
621+
"http://127.0.0.1:28382/blank: failed to parse title"));
622622
}
623623

624624
#[test]

0 commit comments

Comments
 (0)