Skip to content

Commit

Permalink
test: add unit test on GoneError raising during watch request
Browse files Browse the repository at this point in the history
  • Loading branch information
florianvazelle committed Aug 22, 2024
1 parent d6ace51 commit 5c529f5
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion kr8s/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import kr8s
import kr8s.asyncio
from kr8s._exceptions import APITimeoutError
from kr8s._exceptions import APITimeoutError, GoneError
from kr8s.asyncio.objects import Pod, Table


Expand Down Expand Up @@ -314,6 +314,30 @@ async def test_api_timeout() -> None:
await api.version()


async def test_api_gone(example_pod_spec):
pod = await Pod(example_pod_spec)
await pod.create()

i = 0
with pytest.raises(GoneError):
# Start a watch request on the pod with a very small resourceVersion
async for _ in pod.api.async_watch(
pod.endpoint,
namespace=pod.namespace,
field_selector=f"metadata.name={pod.name}",
since=1,
):
# Patch the pod to increment the resourceVersion if needed
await pod.patch({
"metadata": {
"annotations": {"version": str(i)},
}
})
i += 1

await pod.delete()


async def test_lookup_kind():
api = await kr8s.asyncio.api()

Expand Down

0 comments on commit 5c529f5

Please sign in to comment.