fix(cli): look up a deployment by exact name instead of a paged search

This commit is contained in:
Hugo Durand
2026-09-22 15:25:28 -04:00
parent beb3e9c1f1
commit 904478cbec
5 changed files with 93 additions and 13 deletions
@@ -85,13 +85,24 @@ class ControlPlaneDouble:
self.timeline.append(route)
if request.content:
self.bodies[route] = json.loads(request.content)
return self._respond(request.method, request.url.path)
return self._respond(request)
def _respond(self, method: str, path: str) -> httpx.Response:
def _respond(self, request: httpx.Request) -> httpx.Response:
method, path = request.method, request.url.path
if (method, path) == ("GET", "/v2/listeners"):
return httpx.Response(200, json={"resources": self.listeners})
if (method, path) == ("GET", "/v2/deployments"):
return httpx.Response(200, json={"resources": self.existing_deployments})
name = request.url.params.get("name")
return httpx.Response(
200,
json={
"resources": [
deployment
for deployment in self.existing_deployments
if name is None or deployment.get("name") == name
]
},
)
if (method, path) == ("POST", "/v2/deployments"):
if self.create_error is not None:
return httpx.Response(400, text=self.create_error)