Skip to content

Commit

Permalink
checked in test utilties module
Browse files Browse the repository at this point in the history
  • Loading branch information
vsbuffalo committed Aug 24, 2023
1 parent ee1cd7e commit f3b74ea
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
3 changes: 0 additions & 3 deletions src/lib/api/zenodo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ impl ZenodoAPI {
};
let token = auth_keys.get("zenodo".to_string())?;
let base_url = base_url.unwrap_or(BASE_URL.to_string());
println!("Base URL in constructor: {:?}", base_url);
Ok(ZenodoAPI {
base_url,
name: name.to_string(),
Expand All @@ -200,7 +199,6 @@ impl ZenodoAPI {
headers: Option<HeaderMap>,
data: Option<RequestData<T>>) -> Result<Response> {

println!("BASE_URL: {:?}", self.base_url);
let url = format!("{}/{}?access_token={}", self.base_url.trim_end_matches('/'), endpoint.trim_start_matches('/'), self.token);
trace!("request URL: {:?}", &url);

Expand Down Expand Up @@ -265,7 +263,6 @@ impl ZenodoAPI {
}

pub async fn get_files(&self) -> Result<Vec<ZenodoFile>> {
println!("self: {:?}", self);
let id = self.deposition_id.ok_or(anyhow!("Internal Error: Zenodo deposition_id not set."))?;
let url = format!("{}/{}/files", "/deposit/depositions", id);
let response = self.issue_request::<HashMap<String, String>>(Method::GET, &url, None, None).await?;
Expand Down
12 changes: 12 additions & 0 deletions src/lib/test_utilities.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
use anyhow::Result;

pub fn check_error<T>(result: Result<T>, pattern: &str) {
match result {
Ok(_) => assert!(false, "Expected an error, but got Ok"),
Err(err) => {
assert!(err.to_string().contains(pattern),
"Unexpected error {:?} containing pattern \"{:?}\" ",
err, pattern);
}
}
}

0 comments on commit f3b74ea

Please sign in to comment.