mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-10 15:28:34 +01:00
test: add test for bad dir cache files
Signed-off-by: Ruslan Kuprieiev <[email protected]>
This commit is contained in:
@@ -2,6 +2,7 @@ import os
|
||||
|
||||
from dvc.cache import Cache
|
||||
from dvc.system import System
|
||||
from dvc.output import Output
|
||||
|
||||
from tests.basic_env import TestDvc
|
||||
|
||||
@@ -42,3 +43,18 @@ class TestCache(TestDvc):
|
||||
|
||||
self.assertEqual(len(cache), 2)
|
||||
self.assertEqual(cache, expected)
|
||||
|
||||
|
||||
class TestCacheLoadBadDirCache(TestDvc):
|
||||
def _do_test(self, ret):
|
||||
self.assertTrue(isinstance(ret, list))
|
||||
self.assertEqual(len(ret), 0)
|
||||
|
||||
def test(self):
|
||||
fname = 'not-json'
|
||||
self.create(fname, '<clearly>not,json')
|
||||
self._do_test(Output.load_dir_cache(fname))
|
||||
|
||||
fname = 'not-list'
|
||||
self.create(fname, '{"a": "b"}')
|
||||
self._do_test(Output.load_dir_cache(fname))
|
||||
|
||||
Reference in New Issue
Block a user