mirror of
https://github.com/dathere/ckanaction.git
synced 2025-12-27 21:27:01 +00:00
chore: add Debug to CKAN struct and test with refactor
As per https://rust-lang.github.io/api-guidelines/debuggability.html#c-debug.
This commit is contained in:
parent
baf875e177
commit
614ebfbc05
2 changed files with 23 additions and 20 deletions
|
|
@ -8,6 +8,7 @@ use bon::bon;
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
use std::{collections::HashMap, path::PathBuf};
|
use std::{collections::HashMap, path::PathBuf};
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct CKAN {
|
pub struct CKAN {
|
||||||
url: String,
|
url: String,
|
||||||
token: Option<String>,
|
token: Option<String>,
|
||||||
|
|
|
||||||
|
|
@ -10,24 +10,26 @@ pub async fn get_ckan_builder() -> CKAN {
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[tokio::test]
|
||||||
mod tests {
|
#[ignore = "Set values for const at top of tests file locally."]
|
||||||
use super::*;
|
async fn status_show() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
let ckan = get_ckan_builder().await;
|
||||||
#[tokio::test]
|
let response = ckan.status_show().await?;
|
||||||
#[ignore = "Set values for const at top of tests file locally."]
|
assert!(response.is_object());
|
||||||
async fn status_show() -> Result<(), Box<dyn std::error::Error>> {
|
let success = response
|
||||||
let ckan = get_ckan_builder().await;
|
.as_object()
|
||||||
let response = ckan.status_show().await?;
|
.unwrap()
|
||||||
assert!(response.is_object());
|
.get("success")
|
||||||
let success = response
|
.unwrap()
|
||||||
.as_object()
|
.as_bool()
|
||||||
.unwrap()
|
.unwrap();
|
||||||
.get("success")
|
assert!(success);
|
||||||
.unwrap()
|
Ok(())
|
||||||
.as_bool()
|
}
|
||||||
.unwrap();
|
|
||||||
assert!(success);
|
#[tokio::test]
|
||||||
Ok(())
|
async fn print_ckan_struct_with_debug() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
}
|
let ckan = get_ckan_builder().await;
|
||||||
|
assert_eq!(format!("{ckan:?}"), r#"CKAN { url: "", token: Some("") }"#);
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue