Skip to content

Commit 42cb567

Browse files
committed
fix(components/execd): fix smoke api test under windows
1 parent 5c70d93 commit 42cb567

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

components/execd/tests/smoke_api.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
import sys
2929
import time
3030
import uuid
31+
import tempfile
32+
import pathlib
3133

3234
import requests
3335

@@ -106,10 +108,10 @@ def upload_and_download():
106108

107109

108110
def filesystem_smoke():
109-
base_dir = f"/tmp/execd-smoke-{uuid.uuid4().hex}"
110-
sub_dir = f"{base_dir}/sub"
111-
file_path = f"{sub_dir}/hello.txt"
112-
renamed_path = f"{sub_dir}/hello_renamed.txt"
111+
base_dir = os.path.join(tempfile.gettempdir(), f"execd-smoke-{uuid.uuid4().hex}")
112+
sub_dir = os.path.join(base_dir, "sub")
113+
file_path = os.path.join(sub_dir, "hello.txt")
114+
renamed_path = os.path.join(sub_dir, "hello_renamed.txt")
113115

114116
# create dirs
115117
mk = session.post(f"{BASE_URL}/directories", json={sub_dir: {"mode": 0}}, timeout=10)
@@ -131,7 +133,15 @@ def filesystem_smoke():
131133
# search
132134
search = session.get(f"{BASE_URL}/files/search", params={"path": base_dir, "pattern": "*.txt"}, timeout=10)
133135
expect(search.status_code == 200, f"search failed: {search.status_code} {search.text}")
134-
expect(any(f.get("path") == file_path for f in search.json()), "search did not find file")
136+
found = False
137+
for f in search.json():
138+
p = f.get("path")
139+
if not p:
140+
continue
141+
if pathlib.Path(p).resolve() == pathlib.Path(file_path).resolve():
142+
found = True
143+
break
144+
expect(found, "search did not find file")
135145

136146
# replace content
137147
rep = session.post(

0 commit comments

Comments
 (0)