Skip to content

Commit

Permalink
minor bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
aaravm committed Sep 16, 2024
1 parent 6b4bf92 commit 9ffff77
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 11 deletions.
16 changes: 14 additions & 2 deletions cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,14 +257,26 @@ async fn main() -> Result<(), Box<dyn Error>> {
Ok(())
}

/// Example `config.json` file:
/// Loads the configuration from a JSON file.
///
/// # Example `config.json`
///
/// ```json
/// {
/// "base_path": "http://localhost:8000",
/// "user_agent": "username"
/// "user_agent": "Some(User)",
/// "basic_auth": {
/// "username": "your_username",
/// "password": "your_password"
/// },
/// "oauth_access_token": "your_oauth_access_token"
/// }
/// ```
///
/// # Errors
///
/// This function will return an error if the configuration file is missing or malformed.

fn read_configuration_from_file(file_path: &str) -> Result<Configuration, Box<dyn Error>> {
let mut file = File::open(file_path)?;
Expand Down
2 changes: 1 addition & 1 deletion lib/src/clients/tes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
/// ```rust
/// use ga4gh_sdk::clients::tes::TES;
/// use ga4gh_sdk::utils::configuration::Configuration;
/// use ga4gh_sdk::clients::tes::model::ListTasksParams;
/// use ga4gh_sdk::clients::tes::models::ListTasksParams;
///
/// # async fn test_tes_list_tasks() -> Result<(), Box<dyn std::error::Error>> {
/// let config = Configuration::new(url::Url::parse("http://example.com")?);
Expand Down
2 changes: 1 addition & 1 deletion lib/src/tes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::tes::models::TesListTasksResponse;
use crate::tes::models::TesState;
use crate::tes::models::TesTask;
use crate::transport::Transport;
use crate::tes::model::ListTasksParams;
use crate::tes::models::ListTasksParams;
use serde_json;
use serde_json::from_str;
use serde_json::json;
Expand Down
21 changes: 14 additions & 7 deletions lib/tests/funnel_tes.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#[cfg(feature = "integration_tests")]
#[cfg(test)]
mod tests {
use ga4gh_sdk::utils::configuration::Configuration;
use ga4gh_sdk::clients::tes::models::ListTasksParams;
use ga4gh_sdk::clients::tes::models::TesState;
use ga4gh_sdk::clients::tes::models::TesTask;
use ga4gh_sdk::clients::tes::model::ListTasksParams;
use ga4gh_sdk::clients::tes::Task;
use ga4gh_sdk::clients::tes::models::TesState;
use ga4gh_sdk::clients::tes::TES;
use ga4gh_sdk::utils::configuration::Configuration;
use ga4gh_sdk::utils::test_utils::{ensure_funnel_running, setup};

async fn create_task() -> Result<(Task, TES), Box<dyn std::error::Error>> {
Expand All @@ -26,8 +26,12 @@ mod tests {
let task_json = match std::fs::read_to_string(&file_path) {
Ok(content) => content,
Err(e) => {
let current_dir = std::env::current_dir().unwrap_or_else(|_| std::path::PathBuf::from("unknown directory"));
panic!("Unable to read file in directory {:?}: {:?}", current_dir, e);
let current_dir = std::env::current_dir()
.unwrap_or_else(|_| std::path::PathBuf::from("unknown directory"));
panic!(
"Unable to read file in directory {:?}: {:?}",
current_dir, e
);
}
};
let task: TesTask = serde_json::from_str(&task_json).expect("JSON was not well-formatted");
Expand All @@ -54,7 +58,10 @@ mod tests {
match status {
Ok(state) => {
assert!(
matches!(state, TesState::Initializing | TesState::Queued | TesState::Running),
matches!(
state,
TesState::Initializing | TesState::Queued | TesState::Running
),
"Unexpected state: {:?}",
state
);
Expand Down Expand Up @@ -97,4 +104,4 @@ mod tests {
assert!(list.is_ok());
println!("{:?}", list);
}
}
}

0 comments on commit 9ffff77

Please sign in to comment.