newfol/test/testgit.py
brian m. carlson 629aba310b
Add a test to ensure git transactions work.
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
2013-11-16 02:16:19 +00:00

30 lines
875 B
Python
Executable file

#!/usr/bin/python3
import newfol.database
import os
import subprocess
import tempfile
import unittest
class TestGitTransactions(unittest.TestCase):
def setUp(self):
self.tempdir = tempfile.TemporaryDirectory()
fp = open(self.tempdir.name + "/schema", "w")
print("fmt:0:newfol schema file", file=fp)
print("txn:git", file=fp)
fp.close()
def test_all_checked_in(self):
db = newfol.database.Database.load(self.tempdir.name)
db.store()
curdir = os.getcwd()
os.chdir(self.tempdir.name)
output = ""
with subprocess.Popen(["git", "status", "--porcelain"],
stdout=subprocess.PIPE, stderr=subprocess.DEVNULL) as proc:
output = proc.stdout.read()
os.chdir(curdir)
self.assertEqual(output, b"")
if __name__ == '__main__':
unittest.main()