chat: ChatDB now correctly ignores files that contain no valid messages
This commit is contained in:
+6
-1
@@ -156,13 +156,18 @@ class TestChatDB(unittest.TestCase):
|
||||
next_fname = pathlib.Path(self.db_path.name) / '.next'
|
||||
with open(next_fname, 'w') as f:
|
||||
f.write('4')
|
||||
# add some "trash" in order to test if it's correctly handled / ignored
|
||||
self.trash_files = ['.config.yaml', 'foo.yaml', 'bla.txt']
|
||||
for file in self.trash_files:
|
||||
with open(pathlib.Path(self.db_path.name) / file, 'w') as f:
|
||||
f.write('test trash')
|
||||
|
||||
def message_list(self, tmp_dir: tempfile.TemporaryDirectory) -> list[pathlib.Path]:
|
||||
"""
|
||||
List all Message files in the given TemporaryDirectory.
|
||||
"""
|
||||
# exclude '.next'
|
||||
return list(pathlib.Path(tmp_dir.name).glob('*.[ty]*'))
|
||||
return [f for f in pathlib.Path(tmp_dir.name).glob('*.[ty]*') if f.name not in self.trash_files]
|
||||
|
||||
def tearDown(self) -> None:
|
||||
self.db_path.cleanup()
|
||||
|
||||
Reference in New Issue
Block a user