From 2fa2b67a81b6bbb1af175703bf00ebf990bac026 Mon Sep 17 00:00:00 2001
From: chenjiayi <chenjiayi22@huawei.com>
Date: Tue, 21 Nov 2023 20:02:49 +0800
Subject: [PATCH 077/103] refactor(devmaster): rename the create_tmp_rules
 function to create_tmp_file

The function is used to create a temporary file and write content inside it.
It is more proper to have a more general name.
---
 exts/devmaster/src/lib/rules/rules_load.rs | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/exts/devmaster/src/lib/rules/rules_load.rs b/exts/devmaster/src/lib/rules/rules_load.rs
index 999c9692..b035f562 100644
--- a/exts/devmaster/src/lib/rules/rules_load.rs
+++ b/exts/devmaster/src/lib/rules/rules_load.rs
@@ -1724,7 +1724,7 @@ impl RuleToken {
 }
 
 #[cfg(test)]
-mod tests {
+pub(crate) mod tests {
     use basic::fs_util::touch_file;
     use log::init_log;
     use log::Level;
@@ -1736,7 +1736,7 @@ mod tests {
     use std::panic::catch_unwind;
     use std::{fs, path::Path};
 
-    fn create_tmp_rules(dir: &'static str, file: &str, content: &str, truncate: bool) {
+    pub(crate) fn create_tmp_file(dir: &'static str, file: &str, content: &str, truncate: bool) {
         assert!(fs::create_dir_all(dir).is_ok());
         let s = format!("{}/{}", dir, file);
         let p = Path::new(&s);
@@ -1821,7 +1821,7 @@ mod tests {
         ];
 
         for &content in legal_rule.iter() {
-            create_tmp_rules(
+            create_tmp_file(
                 "/tmp/devmaster/test_load_rules",
                 "00-test.rules",
                 content,
@@ -1954,7 +1954,7 @@ mod tests {
         ];
 
         for content in illegal_rule.iter() {
-            create_tmp_rules(
+            create_tmp_file(
                 "/tmp/devmaster/test_load_rules_panic",
                 "00-test.rules",
                 content,
@@ -1990,7 +1990,7 @@ mod tests {
         let illegal = vec!["OWNER=\"xxxx\"", "GROUP=\"xxxx\""];
 
         for &content in legal.iter() {
-            create_tmp_rules(
+            create_tmp_file(
                 "/tmp/devmaster/test_resolve_name_time",
                 "00-test.rules",
                 content,
@@ -2004,7 +2004,7 @@ mod tests {
         }
 
         for &content in illegal.iter() {
-            create_tmp_rules(
+            create_tmp_file(
                 "/tmp/devmaster/test_resolve_name_time",
                 "00-test.rules",
                 content,
-- 
2.33.0

