Преглед изворни кода

1.添加获取账号信息测试
2.修改导出文件打印目录

gepangpang пре 2 година
родитељ
комит
1250d49ba0

+ 1 - 4
global/src/export_utils.rs

@@ -5,15 +5,12 @@ use uuid::Uuid;
 pub fn export_excel(header_array: Vec<&str>, data: Vec<Vec<&str>>, prefix_name: &str) -> String {
     //本地存储路径
     let save_path = "C:/Users/Public/Documents/";
-    //文件代理路径
-    let url_path = "http://127.0.0.1/";
     let _ = std::fs::create_dir(format!("{}rust_export/", save_path));
     // 当前时间
     let date = Local::now().format("%Y-%m-%d").to_string();
     let uid = Uuid::new_v4().to_string()[0..8].to_string();
     let name = if prefix_name == "" { "".to_string() } else { format!("{}_", prefix_name) };
     let file_name = format!("{}rust_export/{}{}_{}.xlsx", save_path, name, date, uid);
-    let url_name = format!("{}rust_export/{}{}_{}.xlsx", url_path, name, date, uid);
     let mut wb = Workbook::create(&file_name);
     let mut sheet = wb.create_sheet("sheet1");
     // 设置行宽
@@ -37,5 +34,5 @@ pub fn export_excel(header_array: Vec<&str>, data: Vec<Vec<&str>>, prefix_name:
         sw.append_row(Default::default())
     }).expect("写入excel错误!");
     wb.close().expect("关闭excel错误!");
-    url_name
+    file_name
 }

+ 2 - 0
global/tests/export_utils_test.rs

@@ -3,6 +3,8 @@ use global::export_utils;
 
 #[tokio::test]
 async fn export_excel() {
+    global::log_utils::init_log_with_trace();
+
     let header = vec!["标题1", "标题2"];
     let data = vec![vec!["第一行数据1", "第一行数据2"], vec!["第二行数据1", "第二行数据2"]];
     let file_name = export_utils::export_excel(header,data,"");

+ 10 - 0
global/tests/get_account_info_test.rs

@@ -0,0 +1,10 @@
+use tracing::trace;
+use global::account_info;
+
+#[tokio::test]
+async fn get_account_info() {
+    global::log_utils::init_log_with_trace();
+
+    let account_info = account_info::get_account_info("../test_account.toml");
+    trace!(?account_info);
+}