1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-11-15 16:46:14 +01:00
github.com_openSUSE_osc/tests/test_git_scm_store.py

50 lines
1.4 KiB
Python
Raw Normal View History

import os
import shutil
import subprocess
import tempfile
import unittest
from osc.git_scm.store import GitStore
class TestGitStore(unittest.TestCase):
def setUp(self):
self.tmpdir = tempfile.mkdtemp(prefix="osc_test")
os.chdir(self.tmpdir)
subprocess.check_output(["git", "init", "-b", "factory"])
subprocess.check_output(["git", "remote", "add", "origin", "https://example.com/packages/my-package.git"])
def tearDown(self):
try:
shutil.rmtree(self.tmpdir)
except OSError:
pass
def test_package(self):
store = GitStore(self.tmpdir)
self.assertEqual(store.package, "my-package")
def test_project(self):
store = GitStore(self.tmpdir)
self.assertEqual(store.project, "openSUSE:Factory")
def test_last_buildroot(self):
store = GitStore(self.tmpdir)
self.assertEqual(store.last_buildroot, None)
store.last_buildroot = ("repo", "arch", "vm_type")
store = GitStore(self.tmpdir)
self.assertEqual(store.last_buildroot, ("repo", "arch", "vm_type"))
def test_scmurl(self):
store = GitStore(self.tmpdir)
self.assertEqual(store.scmurl, "https://example.com/packages/my-package.git")
if not shutil.which("git"):
TestGitStore = unittest.skip("The 'git' executable is not available")(TestGitStore)
if __name__ == "__main__":
unittest.main()