Skip to content

Commit

Permalink
Simplify test error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
mbrubeck committed Mar 29, 2024
1 parent 6b67e60 commit 5c43b03
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 5 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ tokio = { version = "1.36", features = ["fs", "io-util", "net", "rt-multi-thread
url = "2.5.0"

[dev-dependencies]
anyhow = "1.0"
gemini-fetch = "0.2.1"

[profile.release]
Expand Down
5 changes: 2 additions & 3 deletions tests/tests.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use anyhow::anyhow;
use gemini_fetch::{Header, Page, Status};
use std::convert::TryInto;
use std::io::{BufRead, BufReader, Read, Write};
Expand Down Expand Up @@ -129,15 +128,15 @@ impl Drop for Server {
}
}

fn get(args: &[&str], url: &str) -> Result<Page, anyhow::Error> {
fn get(args: &[&str], url: &str) -> Result<Page, String> {
let mut server = Server::new(args);

// actually perform the request
let page = tokio::runtime::Runtime::new().unwrap().block_on(async {
Page::fetch_from(&Url::parse(url).unwrap(), server.get_addr(), None).await
});

server.stop().map_err(|e| anyhow!(e)).and(page)
server.stop().and(page.map_err(|e| e.to_string()))
}

#[test]
Expand Down

0 comments on commit 5c43b03

Please sign in to comment.