diff --git a/tests/scm_data/testrepo/HEAD b/tests/scm_data/testrepo/HEAD new file mode 100644 index 00000000..cb089cd8 --- /dev/null +++ b/tests/scm_data/testrepo/HEAD @@ -0,0 +1 @@ +ref: refs/heads/master diff --git a/tests/scm_data/testrepo/config b/tests/scm_data/testrepo/config new file mode 100644 index 00000000..07d359d0 --- /dev/null +++ b/tests/scm_data/testrepo/config @@ -0,0 +1,4 @@ +[core] + repositoryformatversion = 0 + filemode = true + bare = true diff --git a/tests/scm_data/testrepo/description b/tests/scm_data/testrepo/description new file mode 100644 index 00000000..498b267a --- /dev/null +++ b/tests/scm_data/testrepo/description @@ -0,0 +1 @@ +Unnamed repository; edit this file 'description' to name the repository. diff --git a/tests/scm_data/testrepo/info/exclude b/tests/scm_data/testrepo/info/exclude new file mode 100644 index 00000000..a5196d1b --- /dev/null +++ b/tests/scm_data/testrepo/info/exclude @@ -0,0 +1,6 @@ +# git ls-files --others --exclude-from=.git/info/exclude +# Lines that start with '#' are comments. +# For a project mostly in C, the following would be a good set of +# exclude patterns (uncomment them if you want to use them): +# *.[oa] +# *~ diff --git a/tests/scm_data/testrepo/objects/28/ad5b501c13fc618bb395913a2b47ad90e0f51f b/tests/scm_data/testrepo/objects/28/ad5b501c13fc618bb395913a2b47ad90e0f51f new file mode 100644 index 00000000..c5f08a40 Binary files /dev/null and b/tests/scm_data/testrepo/objects/28/ad5b501c13fc618bb395913a2b47ad90e0f51f differ diff --git a/tests/scm_data/testrepo/objects/54/81faa232d66589e660cc301179867fb00842c9 b/tests/scm_data/testrepo/objects/54/81faa232d66589e660cc301179867fb00842c9 new file mode 100644 index 00000000..35b695c7 Binary files /dev/null and b/tests/scm_data/testrepo/objects/54/81faa232d66589e660cc301179867fb00842c9 differ diff --git a/tests/scm_data/testrepo/objects/d5/819330d12885aae9c026081d7959fae78eab03 b/tests/scm_data/testrepo/objects/d5/819330d12885aae9c026081d7959fae78eab03 new file mode 100644 index 00000000..74d9747f Binary files /dev/null and b/tests/scm_data/testrepo/objects/d5/819330d12885aae9c026081d7959fae78eab03 differ diff --git a/tests/scm_data/testrepo/refs/heads/master b/tests/scm_data/testrepo/refs/heads/master new file mode 100644 index 00000000..61f3fc7d --- /dev/null +++ b/tests/scm_data/testrepo/refs/heads/master @@ -0,0 +1 @@ +5481faa232d66589e660cc301179867fb00842c9 diff --git a/tests/test_scm.py b/tests/test_scm.py index 8e224804..f4c4c2cb 100644 --- a/tests/test_scm.py +++ b/tests/test_scm.py @@ -28,14 +28,14 @@ import unittest import module_build_service.scm -this_repo_path = 'file://' + os.path.abspath(os.path.dirname(__file__) + "/..") +repo_path = 'file://' + os.path.dirname(__file__) + "/scm_data/testrepo" class TestSCMModule(unittest.TestCase): def setUp(self): self.tempdir = tempfile.mkdtemp() - self.repodir = self.tempdir + '/module-build-service' + self.repodir = self.tempdir + '/testrepo' def tearDown(self): if os.path.exists(self.tempdir): @@ -43,24 +43,24 @@ class TestSCMModule(unittest.TestCase): def test_simple_local_checkout(self): """ See if we can clone a local git repo. """ - scm = module_build_service.scm.SCM(this_repo_path) + scm = module_build_service.scm.SCM(repo_path) scm.checkout(self.tempdir) files = os.listdir(self.repodir) - assert 'LICENSE' in files, "LICENSE not in %r" % files + assert 'foo' in files, "foo not in %r" % files def test_local_get_latest_is_sane(self): """ See that a hash is returned by scm.get_latest. """ - scm = module_build_service.scm.SCM(this_repo_path) + scm = module_build_service.scm.SCM(repo_path) latest = scm.get_latest(branch='master') - error = "%r is %i chars long, not 40" % (latest, len(latest)) - assert len(latest) == 40, error + target = '5481faa232d66589e660cc301179867fb00842c9' + assert latest == target, "%r != %r" % (latest, target) def test_local_get_latest_unclean_input(self): """ Ensure that shell characters aren't handled poorly. https://pagure.io/fm-orchestrator/issue/329 """ - scm = module_build_service.scm.SCM(this_repo_path) + scm = module_build_service.scm.SCM(repo_path) assert scm.scheme == 'git', scm.scheme fname = tempfile.mktemp(suffix='mbs-scm-test') scm.get_latest(branch='master; touch %s' % fname)