Skip to content

Commit

Permalink
WIP: Assert that write side does not operate on fake workspace names
Browse files Browse the repository at this point in the history
  • Loading branch information
mhsdesign committed Jun 29, 2024
1 parent b8d48c4 commit 10011fb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ public function getContentGraph(WorkspaceName $workspaceName): ContentGraphInter
return $this->overridenContentGraphInstances[$workspaceName->value];
}

if ($workspaceName->isReferencingUnusedContentStream()) {
throw new \RuntimeException(sprintf('Expected actual workspace name. Got a workspace name referencing an unused content stream: "%s" instead.', $workspaceName->getReferencingUnusedContentStreamId()->value), 1719648458);
}

return $this->contentRepository->getContentGraph($workspaceName);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -900,6 +900,10 @@ private function handleChangeWorkspaceOwner(

private function requireWorkspaceToNotExist(WorkspaceName $workspaceName, CommandHandlingDependencies $commandHandlingDependencies): void
{
if ($workspaceName->isReferencingUnusedContentStream()) {
throw new \RuntimeException(sprintf('Expected actual workspace name. Got a workspace name referencing an unused content stream: "%s" instead.', $workspaceName->getReferencingUnusedContentStreamId()->value), 1719648458);
}

try {
$commandHandlingDependencies->getContentGraph($workspaceName);
} catch (WorkspaceDoesNotExist) {
Expand All @@ -918,6 +922,10 @@ private function requireWorkspaceToNotExist(WorkspaceName $workspaceName, Comman
*/
private function requireWorkspace(WorkspaceName $workspaceName, WorkspaceFinder $workspaceFinder): Workspace
{
if ($workspaceName->isReferencingUnusedContentStream()) {
throw new \RuntimeException(sprintf('Expected actual workspace name. Got a workspace name referencing an unused content stream: "%s" instead.', $workspaceName->getReferencingUnusedContentStreamId()->value), 1719648458);
}

$workspace = $workspaceFinder->findOneByName($workspaceName);
if (is_null($workspace)) {
throw WorkspaceDoesNotExist::butWasSupposedTo($workspaceName);
Expand Down

0 comments on commit 10011fb

Please sign in to comment.