44from packaging import version
55
66from posit .connect import Client
7+ from posit .connect .system import SystemRuntimeCache
8+ from posit .connect .tasks import Task
79
810from . import CONNECT_VERSION
911
@@ -28,5 +30,31 @@ def teardown_class(cls):
2830 cls .content .delete ()
2931
3032 def test_runtime_caches (self ):
31- caches = self .client .system .caches .runtime .find ()
32- assert len (caches ) > 0
33+ runtimes = self .client .system .caches .runtime .find ()
34+ assert len (runtimes ) > 0
35+
36+ def test_runtime_cache_destroy (self ):
37+ # Find existing runtime caches
38+ runtimes : list [SystemRuntimeCache ] = self .client .system .caches .runtime .find ()
39+ assert len (runtimes ) > 0
40+
41+ # Get the first cache for testing
42+ cache = runtimes [0 ]
43+ assert isinstance (cache , SystemRuntimeCache )
44+
45+ # Test dry run destroy (should return None and not actually destroy)
46+ result = cache .destroy (dry_run = True )
47+ assert result is None
48+
49+ # Verify cache still exists after dry run
50+ runtimes_after_dry_run = self .client .system .caches .runtime .find ()
51+ assert len (runtimes_after_dry_run ) == len (runtimes )
52+
53+ # Test actual destroy
54+ task : Task = cache .destroy ()
55+ assert isinstance (task , Task )
56+ task .wait_for ()
57+
58+ # Verify cache was removed
59+ runtimes_after_destroy = self .client .system .caches .runtime .find ()
60+ assert len (runtimes_after_destroy ) == len (runtimes ) - 1
0 commit comments