Skip to content

Commit bf58c52

Browse files
committed
refactor(tests): follow other tests conventions
1 parent 31636c7 commit bf58c52

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

tests/cli/cli_external_actions.rs

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,29 @@
55
66
use super::common::*;
77
use std::{fs, thread::sleep, time::Duration};
8-
use tempfile::TempDir;
98

109
// ANSI escape sequences for function keys
1110
const F8_KEY: &str = "\x1b[19~";
1211
const F9_KEY: &str = "\x1b[20~";
1312

13+
/// Helper to create a custom cable directory with external actions.
14+
fn write_toml_config(
15+
cable_dir: &std::path::Path,
16+
filename: &str,
17+
content: &str,
18+
) {
19+
let toml_path = cable_dir.join(filename);
20+
fs::write(&toml_path, content).unwrap();
21+
}
22+
1423
/// Tests that external actions execute properly when triggered by keybindings.
1524
#[test]
1625
fn test_external_action_lsman_with_f9() {
1726
let mut tester = PtyTester::new();
1827

19-
// Create a temporary directory for the custom cable
20-
let temp_dir = TempDir::new().unwrap();
21-
let cable_dir = temp_dir.path();
28+
// Use TARGET_DIR for consistency with other tests
29+
let cable_dir = std::path::Path::new(TARGET_DIR).join("custom_cable");
30+
fs::create_dir_all(&cable_dir).unwrap();
2231

2332
// Create a custom files.toml with external actions
2433
let files_toml_content = r#"
@@ -49,8 +58,7 @@ description = "show stats"
4958
command = "ls '{}'"
5059
"#;
5160

52-
let files_toml_path = cable_dir.join("files.toml");
53-
fs::write(&files_toml_path, files_toml_content).unwrap();
61+
write_toml_config(&cable_dir, "files.toml", files_toml_content);
5462

5563
// Use the LICENSE file as input since it exists in the repo
5664
let mut cmd = tv();
@@ -82,9 +90,8 @@ command = "ls '{}'"
8290
fn test_external_action_thebatman_with_f8() {
8391
let mut tester = PtyTester::new();
8492

85-
// Create a temporary directory for the custom cable
86-
let temp_dir = TempDir::new().unwrap();
87-
let cable_dir = temp_dir.path();
93+
let cable_dir = std::path::Path::new(TARGET_DIR).join("custom_cable_f8");
94+
fs::create_dir_all(&cable_dir).unwrap();
8895

8996
// Create a custom files.toml with external actions
9097
let files_toml_content = r#"
@@ -115,8 +122,7 @@ description = "show stats"
115122
command = "ls '{}'"
116123
"#;
117124

118-
let files_toml_path = cable_dir.join("files.toml");
119-
fs::write(&files_toml_path, files_toml_content).unwrap();
125+
write_toml_config(&cable_dir, "files.toml", files_toml_content);
120126

121127
// Use the LICENSE file as input since it exists in the repo
122128
let mut cmd = tv();
@@ -141,3 +147,4 @@ command = "ls '{}'"
141147
// Check that the process has finished
142148
PtyTester::assert_exit_ok(&mut child, DEFAULT_DELAY);
143149
}
150+

0 commit comments

Comments
 (0)