ops: install narrowly scoped bounded disk maintenance via CI
Owned disk maintenance only / maintenance (push) Successful in 11s
Owned disk maintenance only / maintenance (push) Successful in 11s
This commit is contained in:
1 parent
dc34c57a0c
commit
6dec2c1469
4 files changed
+115
No files matched your search
@@ -0,0 +1,20 @@
|
||||
import importlib.util,pathlib,tempfile,unittest,os,time
|
||||
spec=importlib.util.spec_from_file_location('disk',pathlib.Path(__file__).with_name('managed-disk.py'))
|
||||
class Tests(unittest.TestCase):
|
||||
def test_expiry_and_escape(self):
|
||||
self.assertTrue(pathlib.Path(spec.origin).exists(),'managed retention implementation missing')
|
||||
m=importlib.util.module_from_spec(spec);spec.loader.exec_module(m)
|
||||
with tempfile.TemporaryDirectory() as d:
|
||||
r=pathlib.Path(d);old=r/'old';old.mkdir();(old/'.disposable-test').write_text('canina-managed-test-v1\n');(old/'result').write_text('fixture');os.utime(old,(1,1))
|
||||
unknown=r/'unknown';unknown.mkdir();os.utime(unknown,(1,1))
|
||||
outside=r/'source';outside.mkdir();(outside/'important').write_text('preserve');os.symlink(outside,r/'escape')
|
||||
self.assertEqual(m.retire(r,now=time.time()),['old']);self.assertEqual(m.retire(r,now=time.time()),[])
|
||||
self.assertTrue((outside/'important').exists());self.assertTrue(unknown.exists());self.assertTrue((r/'escape').is_symlink())
|
||||
def test_open_artifact_is_preserved(self):
|
||||
m=importlib.util.module_from_spec(spec);spec.loader.exec_module(m)
|
||||
with tempfile.TemporaryDirectory() as d:
|
||||
r=pathlib.Path(d);p=r/'busy';p.mkdir();(p/'.disposable-test').write_text('canina-managed-test-v1\n');f=(p/'result').open('w');os.utime(p,(1,1))
|
||||
try:self.assertEqual(m.retire(r),[])
|
||||
finally:f.close()
|
||||
self.assertEqual(m.retire(r),['busy'])
|
||||
if __name__=='__main__':unittest.main()
|
||||
Reference in new issue
Block a user