test/objectstore: always setup a fresh store

There is little use in sharing the store between test, quite to
opposite: all tests expect a clean store and some currently set
that up themselves. Create a fresh store for each test.
This commit is contained in:
Christian Kellner 2022-08-22 15:53:16 +00:00
parent 0a41742d27
commit afc82ee465

View file

@ -26,16 +26,11 @@ def store_path(store: objectstore.ObjectStore, ref: str, path: str) -> bool:
@unittest.skipUnless(test.TestBase.can_bind_mount(), "root-only")
class TestObjectStore(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.store = os.getenv("OSBUILD_TEST_STORE")
if not cls.store:
cls.store = tempfile.mkdtemp(prefix="osbuild-test-", dir="/var/tmp")
def setUp(self):
self.store = tempfile.mkdtemp(prefix="osbuild-test-", dir="/var/tmp")
@classmethod
def tearDownClass(cls):
if not os.getenv("OSBUILD_TEST_STORE"):
shutil.rmtree(cls.store)
def tearDown(self):
shutil.rmtree(self.store)
def test_basic(self):
# always use a temporary store so item counting works