Skip to content

Commit

Permalink
added service-info unit test using funnel
Browse files Browse the repository at this point in the history
  • Loading branch information
aaravm committed Jun 22, 2024
1 parent e9ccf43 commit d4faee2
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 10 deletions.
20 changes: 20 additions & 0 deletions lib/src/serviceinfo/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ mod tests {
use super::*;
use std::ptr::eq;
use mockall::predicate::*;
use tokio;

#[tokio::test]
async fn test_get_service_info() {
Expand All @@ -61,6 +62,25 @@ mod tests {
// assert_eq!(result.unwrap().id, "test");
// assert_eq!(result.unwrap().name, "test");
}
#[tokio::test]
async fn test_get_service_info_from_funnel() {
// Initialize the Transport struct to point to your local Funnel server
let config = Configuration::new("http://localhost:8000".to_string(), None, None);
let transport = Transport::new(&config);

// Create a ServiceInfo instance using the local Transport
let service_info = ServiceInfo::new(transport);

// Call get_service_info and print the result
match service_info.get_service_info().await {
Ok(service) => {
println!("Service Info: {:?}", service);
},
Err(e) => {
println!("Failed to get service info: {}", e);
},
}
}
}

// CHECK WHAT ALL ARE REQUIRED
Expand Down
20 changes: 10 additions & 10 deletions lib/src/tes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ impl TES {
pub async fn new(config: &Configuration) -> Self {
let transport = &Transport::new(config);
let service_info = &ServiceInfo::new(transport.clone());
let _resp = service_info.get_service_info().await;
// assert_eq!(_resp.name, "TES");
let resp = service_info.get_service_info().await;
assert_eq!(resp.unwrap().r#type.artifact, "tes");
TES {
config: config.clone(),
transport: transport.clone(),
Expand Down Expand Up @@ -106,7 +106,7 @@ mod tests {

async fn create_task() -> Result<String, Box<dyn std::error::Error>> {
let mut config = Configuration::default();
config.set_base_path("http://localhost:8080"); // expecting TES/Funnel, TODO autorun
config.set_base_path("http://localhost:8000"); // expecting TES/Funnel, TODO autorun
let tes = TES::new(&config).await;

let task_json = std::fs::read_to_string("./lib/sample/grape.tes").expect("Unable to read file");
Expand All @@ -124,14 +124,14 @@ 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() {
env_logger::init();
// #[tokio::test]
// async fn test_task_status() {
// env_logger::init();

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 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?);
// }
}

// not sure if we need the code bellow, it was autogenerated by openapi-generator as i understand
Expand Down

0 comments on commit d4faee2

Please sign in to comment.