Skip to content

Commit

Permalink
feat: fix test bug
Browse files Browse the repository at this point in the history
  • Loading branch information
jincheng.zhang committed Apr 2, 2024
1 parent dda6937 commit 0d02f52
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 6 deletions.
2 changes: 2 additions & 0 deletions crates/netpurr/src/panels/manager_testcase_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ impl ManagerTestcasePanel {
testcases.insert(self.edit_name.clone(),new_testcase);
self.need_edit_name = None;
remove_name_op = Some(name);
is_change = true;
}
}
}else {
Expand All @@ -109,6 +110,7 @@ impl ManagerTestcasePanel {
self.need_edit_name = Some(name.to_string());
self.edit_name = name.to_string();
self.need_focus_edit = true;
ui.close_menu();
}
if ui.button("Remove").clicked() {
remove_name_op = Some(name);
Expand Down
3 changes: 2 additions & 1 deletion crates/netpurr/src/panels/response_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ impl ResponsePanel {
Color32::RED,
),
TestStatus::WAIT => HighlightValue::None,
TestStatus::SKIP => HighlightValue::None
TestStatus::SKIP => HighlightValue::None,
TestStatus::RUNNING => HighlightValue::None
},
}
}
Expand Down
1 change: 1 addition & 0 deletions crates/netpurr/src/panels/rest_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ impl RestPanel {
}
TestStatus::WAIT => {}
TestStatus::SKIP => {}
TestStatus::RUNNING => {}
}
}
}
Expand Down
11 changes: 6 additions & 5 deletions crates/netpurr/src/panels/test_editor_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,14 +155,14 @@ impl TestEditorPanel {
Panel::PreRequestScript => {
match test_item {
TestItem::Folder(_, f) => {
if f.borrow().pre_request_script.is_empty() {
if f.borrow().pre_request_script.trim().is_empty() {
utils::build_with_count_ui_header(panel.to_string(), HighlightValue::None, ui)
} else {
utils::build_with_count_ui_header(panel.to_string(), HighlightValue::Has, ui)
}
}
TestItem::Record(_, f, r) => {
if f.borrow().requests.get(r).unwrap().pre_request_script().is_empty() {
if f.borrow().requests.get(r).unwrap().pre_request_script().trim().is_empty() {
utils::build_with_count_ui_header(panel.to_string(), HighlightValue::None, ui)
} else {
utils::build_with_count_ui_header(panel.to_string(), HighlightValue::Has, ui)
Expand All @@ -173,14 +173,14 @@ impl TestEditorPanel {
Panel::TestScript => {
match test_item {
TestItem::Folder(_, f) => {
if f.borrow().test_script.is_empty() {
if f.borrow().test_script.trim().is_empty() {
utils::build_with_count_ui_header(panel.to_string(), HighlightValue::None, ui)
} else {
utils::build_with_count_ui_header(panel.to_string(), HighlightValue::Has, ui)
}
}
TestItem::Record(_, f, r) => {
if f.borrow().requests.get(r).unwrap().test_script().is_empty() {
if f.borrow().requests.get(r).unwrap().test_script().trim().is_empty() {
utils::build_with_count_ui_header(panel.to_string(), HighlightValue::None, ui)
} else {
utils::build_with_count_ui_header(panel.to_string(), HighlightValue::Has, ui)
Expand Down Expand Up @@ -588,8 +588,9 @@ impl TestEditorPanel {
}
TestStatus::PASS => rich_text = rich_text.background_color(Color32::DARK_GREEN),
TestStatus::FAIL => rich_text = rich_text.background_color(Color32::DARK_RED),
TestStatus::WAIT => rich_text = rich_text.background_color(Color32::DARK_BLUE),
TestStatus::WAIT => rich_text = rich_text.background_color(Color32::DARK_GRAY),
TestStatus::SKIP => rich_text = rich_text.background_color(Color32::GRAY),
TestStatus::RUNNING => rich_text = rich_text.background_color(Color32::DARK_BLUE),
};
rich_text.append_to(
&mut request_test_result_name_layout_job,
Expand Down
1 change: 1 addition & 0 deletions crates/netpurr_core/src/data/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ impl TestResult {
pub enum TestStatus {
None,
WAIT,
RUNNING,
PASS,
FAIL,
SKIP
Expand Down
10 changes: 10 additions & 0 deletions crates/netpurr_core/src/runner/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,16 @@ impl Runner {
.enable_all()
.build()
.unwrap();
let mut test_result =TestResult::default();
test_result.status = TestStatus::RUNNING;
test_group_run_result.write().unwrap().add_result(Ok(TestRunResult{
request: run_request_info.request.clone(),
response: None,
test_result,
collection_path: run_request_info.collection_path.clone(),
request_name: run_request_info.request_name.clone(),
testcase: run_request_info.testcase.clone(),
}));
runtime.block_on(async {
let result = Self::send_rest_with_script_async(
run_request_info.clone(),
Expand Down
4 changes: 4 additions & 0 deletions crates/netpurr_core/src/runner/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ impl ResultTreeFolder {
TestStatus::PASS => {}
TestStatus::FAIL => case_status = TestStatus::FAIL,
TestStatus::SKIP => case_status = TestStatus::SKIP,
TestStatus::RUNNING => case_status = TestStatus::WAIT,
}
case_folders.insert(name.to_string(), child_folder);
}
Expand All @@ -109,6 +110,8 @@ impl ResultTreeFolder {
request_status = r.test_result.status.clone();
if request_status == TestStatus::FAIL {
case_status = TestStatus::FAIL;
}else if request_status == TestStatus::RUNNING {
case_status = TestStatus::RUNNING;
}
}
Err(e) => {
Expand Down Expand Up @@ -139,6 +142,7 @@ impl ResultTreeFolder {
TestStatus::PASS => {}
TestStatus::FAIL => folder_status = TestStatus::FAIL,
TestStatus::SKIP => folder_status = TestStatus::SKIP,
TestStatus::RUNNING => folder_status = TestStatus::WAIT
}
}
new_result_tree_folder.status = folder_status.clone();
Expand Down

0 comments on commit 0d02f52

Please sign in to comment.