Skip to content

Commit 5d33db8

Browse files
committed
Fix: simplify/correct tests
1 parent 2096b09 commit 5d33db8

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

server/src/webserver/vscode.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,7 @@ mod test {
665665
use std::{
666666
fs,
667667
io::Error,
668-
path::{self, Path, PathBuf, MAIN_SEPARATOR_STR},
668+
path::{self, Path, PathBuf},
669669
thread,
670670
time::{Duration, SystemTime},
671671
};
@@ -951,7 +951,7 @@ mod test {
951951
// Compare these as strings -- we want to ensure the path separator is
952952
// correct for the current platform.
953953
assert_eq!(
954-
format!("{}{MAIN_SEPARATOR_STR}none.py", test_dir.to_str().unwrap()),
954+
test_dir.join("none.py").to_str().unwrap().to_string(),
955955
msg.to_string_lossy()
956956
);
957957
assert_eq!(em.id, 3.0);
@@ -984,10 +984,11 @@ mod test {
984984
open_client(&mut ws_ide).await;
985985

986986
// Message ids: IDE - 4->7, Server - 3, Client - 2.
987-
let file_path = format!(
988-
"{}{MAIN_SEPARATOR_STR}only-in-ide.py",
989-
test_dir.to_str().unwrap()
990-
);
987+
let file_path = test_dir
988+
.join("only-in-ide.py")
989+
.to_str()
990+
.unwrap()
991+
.to_string();
991992
send_message(
992993
&mut ws_ide,
993994
&EditorMessage {
@@ -1242,11 +1243,11 @@ mod test {
12421243
#[actix_web::test]
12431244
async fn test_vscode_ide_websocket6() {
12441245
let connection_id = "test-connection-id6";
1245-
let (temp_dir, _, mut ws_ide, mut ws_client) = prep_test!(connection_id).await;
1246+
let (temp_dir, test_dir, mut ws_ide, mut ws_client) = prep_test!(connection_id).await;
12461247
open_client(&mut ws_ide).await;
12471248

12481249
// Message ids: IDE - 4, Server - 3, Client - 2->5.
1249-
let file_path = temp_dir.path().join("foo.py").to_string_lossy().to_string();
1250+
let file_path = test_dir.join("foo.py").to_string_lossy().to_string();
12501251
send_message(
12511252
&mut ws_client,
12521253
&EditorMessage {
@@ -1324,7 +1325,7 @@ mod test {
13241325
open_client(&mut ws_ide).await;
13251326

13261327
// Message ids: IDE - 4, Server - 3, Client - 2->5.
1327-
let file_path = format!("{}{MAIN_SEPARATOR_STR}test.py", test_dir.to_str().unwrap());
1328+
let file_path = test_dir.join("test.py").to_str().unwrap().to_string();
13281329
send_message(
13291330
&mut ws_client,
13301331
&EditorMessage {
@@ -1388,8 +1389,8 @@ mod test {
13881389
let em = read_message(&mut ws_ide).await;
13891390
let msg = cast!(em.message, EditorMessageContents::LoadFile);
13901391
assert_eq!(
1391-
path::absolute(Path::new(&msg)).unwrap(),
1392-
path::absolute(format!("{}/test.py", test_dir.to_str().unwrap())).unwrap()
1392+
fs::canonicalize(&msg).unwrap(),
1393+
fs::canonicalize(test_dir.join("test.py")).unwrap()
13931394
);
13941395
assert_eq!(em.id, 3.0);
13951396

0 commit comments

Comments
 (0)