Skip to content

Commit

Permalink
fix: refine codes
Browse files Browse the repository at this point in the history
  • Loading branch information
halajohn committed Oct 23, 2024
1 parent 0fdfa67 commit 27929e4
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion core/src/ten_manager/src/dev_server/graphs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use super::{
use ten_rust::pkg_info::pkg_type::PkgType;

#[derive(Serialize, Deserialize, Debug, PartialEq)]
struct RespGraph {
pub struct RespGraph {
name: String,
auto_start: bool,
}
Expand Down
2 changes: 1 addition & 1 deletion core/src/ten_manager/src/dev_server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ mod messages;
mod mock;
mod packages;
mod property;
mod response;
pub mod response;
mod version;

use std::sync::{Arc, RwLock};
Expand Down
2 changes: 1 addition & 1 deletion core/src/ten_manager/tests/cmd_check_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ async fn test_cmd_check_app_in_graph_cannot_be_localhost() {
)
.await;

// 'localhost' is not allowed in graph definition
// 'localhost' is not allowed in graph definition.
assert!(result.is_err());
eprintln!("{:?}", result);

Expand Down
11 changes: 8 additions & 3 deletions core/src/ten_manager/tests/cmd_dev_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ use actix_web::{http::StatusCode, test, web, App};

use ten_manager::{
config::TmanConfig,
dev_server::{graphs::get_graphs, DevServerState},
dev_server::{
graphs::{get_graphs, RespGraph},
response::ApiResponse,
DevServerState,
},
};

#[actix_rt::test]
Expand Down Expand Up @@ -77,10 +81,11 @@ async fn test_cmd_dev_server_graphs_app_property_not_exist() {

let body = test::read_body(resp).await;
let body_str = std::str::from_utf8(&body).unwrap();
let json: serde_json::Value = serde_json::from_str(body_str).unwrap();
let json =
serde_json::from_str::<ApiResponse<Vec<RespGraph>>>(body_str).unwrap();

let pretty_json = serde_json::to_string_pretty(&json).unwrap();
println!("Response body: {}", pretty_json);

assert!(json["data"].as_array().unwrap().is_empty());
assert!(json.data.is_empty());
}

0 comments on commit 27929e4

Please sign in to comment.