Skip to content

Commit 000e900

Browse files
Add error handling for directory operations in tests
- Add error checking for mkdir and rename operations - Throw descriptive exceptions if operations fail - Helps diagnose issues with test workspace setup Co-authored-by: Manuel Kießling <manuel@kiessling.net>
1 parent 003b9b9 commit 000e900

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

tests/Integration/WorkspaceMgmt/WorkspaceGitServiceTest.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,14 +157,22 @@ private function createTestWorkspace(): Workspace
157157

158158
// Move test repo to the workspace root location
159159
if (!is_dir($this->workspaceRoot)) {
160-
mkdir($this->workspaceRoot, 0777, true);
160+
$result = mkdir($this->workspaceRoot, 0777, true);
161+
if (!$result) {
162+
throw new \RuntimeException('Failed to create workspace root directory: ' . $this->workspaceRoot);
163+
}
161164
}
162165

163166
$targetPath = $this->workspaceRoot . '/' . $workspaceId;
164167
if (is_dir($targetPath)) {
165168
$this->removeDirectory($targetPath);
166169
}
167-
rename($this->testRepoPath, $targetPath);
170+
171+
$renameResult = rename($this->testRepoPath, $targetPath);
172+
if (!$renameResult) {
173+
throw new \RuntimeException('Failed to rename ' . $this->testRepoPath . ' to ' . $targetPath);
174+
}
175+
168176
$this->testRepoPath = $targetPath;
169177

170178
return $workspace;

tests/Integration/WorkspaceMgmt/WorkspaceMgmtFacadeGitInfoTest.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,14 +214,22 @@ private function createTestWorkspace(): Workspace
214214

215215
// Move test repo to the workspace root location
216216
if (!is_dir($this->workspaceRoot)) {
217-
mkdir($this->workspaceRoot, 0777, true);
217+
$result = mkdir($this->workspaceRoot, 0777, true);
218+
if (!$result) {
219+
throw new \RuntimeException('Failed to create workspace root directory: ' . $this->workspaceRoot);
220+
}
218221
}
219222

220223
$targetPath = $this->workspaceRoot . '/' . $workspaceId;
221224
if (is_dir($targetPath)) {
222225
$this->removeDirectory($targetPath);
223226
}
224-
rename($this->testRepoPath, $targetPath);
227+
228+
$renameResult = rename($this->testRepoPath, $targetPath);
229+
if (!$renameResult) {
230+
throw new \RuntimeException('Failed to rename ' . $this->testRepoPath . ' to ' . $targetPath);
231+
}
232+
225233
$this->testRepoPath = $targetPath;
226234

227235
return $workspace;

0 commit comments

Comments
 (0)