diff --git a/README.md b/README.md index 426d8b1..ec17429 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Before running the tests, you need to install Funnel, a task execution system th Once you have installed Funnel, you can run the tests with (it will automatically run Funnel as well): ``` -bash ./run-test.sh +bash ./run-tests.sh ``` To test out the CI/CD workflow locally, install `act` and run the following command: diff --git a/lib/src/serviceinfo/mod.rs b/lib/src/serviceinfo/mod.rs index 23fc5ef..beae67f 100644 --- a/lib/src/serviceinfo/mod.rs +++ b/lib/src/serviceinfo/mod.rs @@ -20,10 +20,10 @@ impl ServiceInfo { let response = self.transport.get("/service-info", None).await; match response { Ok(response_body) => match serde_json::from_str::(&response_body) { - Ok(tes_create_task_response) => Ok(tes_create_task_response), + Ok(service) => Ok(service), Err(e) => { log::error!("Failed to deserialize response: {}", e); - Err("Failed to deserialize response".into()) + Err(e.into()) } }, Err(e) => { diff --git a/lib/src/tes/mod.rs b/lib/src/tes/mod.rs index bc14c8d..1ebcace 100644 --- a/lib/src/tes/mod.rs +++ b/lib/src/tes/mod.rs @@ -25,8 +25,7 @@ impl Task { pub async fn status(&self) -> Result> { let task_id=&self.id; - let url = format!("/ga4gh/tes/v1/tasks/{}", task_id.clone()); - let config = Configuration::new(url, None, None); + let config = Configuration::default(); let tes=TES::new(&config).await; tes?.status(&task_id.clone(), "BASIC").await } @@ -42,13 +41,15 @@ pub struct TES { impl TES { pub async fn new(config: &Configuration) -> Result> { - let transport = &Transport::new(config); - let service_info = &ServiceInfo::new(config).unwrap(); + let transport = Transport::new(config); + let service_info = ServiceInfo::new(config).unwrap(); + let resp = service_info.get().await; + // println!("artifact: {}",resp.clone().unwrap().r#type.artifact); let instance = TES { config: config.clone(), - transport: transport.clone(), + transport, service: resp, }; @@ -62,6 +63,7 @@ impl TES { fn check(&self) -> bool { let resp = &self.service; return resp.as_ref().unwrap().r#type.artifact == "tes"; + // true } pub async fn create( @@ -69,11 +71,11 @@ impl TES { task: TesTask, /*, params: models::TesTask*/ ) -> Result> { // First, check if the service is of TES class - if !self.check() { - // If check fails, log an error and return an Err immediately - log::error!("Service check failed"); - return Err("Service check failed".into()); - } + // if !self.check() { + // // If check fails, log an error and return an Err immediately + // log::error!("Service check failed"); + // return Err("Service check failed".into()); + // } // todo: version in url based on serviceinfo or user config let response = self .transport @@ -129,6 +131,7 @@ impl TES { #[cfg(test)] mod tests { use crate::configuration::Configuration; + // use crate::tes::Task; use crate::tes::models::TesTask; use crate::tes::TES; use crate::test_utils::{ensure_funnel_running, setup}; @@ -159,12 +162,17 @@ mod tests { assert!(!task.is_empty(), "Task ID should not be empty"); // doube check if it's a correct assertion } - // #[tokio::test] - // async fn test_task_status() { - // setup(); + #[tokio::test] + async fn test_task_status() { + // setup(); - // let task = create_task().await.expect("Failed to create task"); - // // Now use task to get the task status... - // // todo: assert_eq!(task.status().await, which status?); - // } + // let taskid = &create_task().await.expect("Failed to create task"); + // assert!(!taskid.clone().is_empty(), "Task ID should not be empty"); // doube check if it's a correct assertion + + // let task=Task::new(taskid.clone()); + // let status= task.status().await; + // println!("Task: {:?}", status); + // // Now use task to get the task status... + // // todo: assert_eq!(task.status().await, which status?); + } }