diff options
author | Guido Günther <agx@sigxcpu.org> | 2011-03-18 11:12:22 +0100 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2011-03-18 19:59:52 +0100 |
commit | fadcfcb35b264f9e9d8762b590512f9049ecff5e (patch) | |
tree | 372b54e56be69b94d5c648f0bc41642c97c415ed /tests | |
parent | ddf5ea3883723f9a64845511583b6dad8ff3600d (diff) | |
download | git-buildpackage-fadcfcb35b264f9e9d8762b590512f9049ecff5e.tar.gz git-buildpackage-fadcfcb35b264f9e9d8762b590512f9049ecff5e.tar.bz2 git-buildpackage-fadcfcb35b264f9e9d8762b590512f9049ecff5e.zip |
gbp: Add git.archive() and git.{has,get,update,add}_submodules()
and testcases.
Heavily based on work by Sean Finney and Chow Loong Jin
Diffstat (limited to 'tests')
-rw-r--r-- | tests/04_test_gbp_submodules.py | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/tests/04_test_gbp_submodules.py b/tests/04_test_gbp_submodules.py new file mode 100644 index 00000000..c48cac45 --- /dev/null +++ b/tests/04_test_gbp_submodules.py @@ -0,0 +1,84 @@ +# vim: set fileencoding=utf-8 : + +import os +import shutil +import tempfile + +import gbp.git +import gbp.command_wrappers + +top = None + +repo = None +repo_dir = None + +submodule = None +submodule_dir = None + +def setup(): + global repo, repo_dir, submodule, submodule_dir, top + + top = os.path.abspath(os.curdir) + + repo_dir = os.path.join(top, 'gbp_%s_repo' % __name__) + repo = gbp.git.create_repo(repo_dir) + + submodule_dir = os.path.join(top, 'gbp_%s_submodule' % __name__) + submodule = gbp.git.create_repo(submodule_dir) + + os.chdir(repo_dir) + + +def teardown(): + os.chdir(top) + if not os.getenv("GBP_TESTS_NOCLEAN"): + if repo_dir: + shutil.rmtree(repo_dir) + if submodule_dir: + shutil.rmtree(submodule_dir) + + +def test_empty_has_submodules(): + """Test empty repo for submodules""" + assert not repo.has_submodules() + + +def _add_dummy_data(): + shutil.copy(".git/HEAD", "testfile") + gbp.command_wrappers.GitAdd()(['-f', '.']) + gbp.command_wrappers.GitCommand("commit", ["-mfoo", "-a"])() + + +def test_add_files(): + """Add some dummy data""" + _add_dummy_data() + assert True + + +def test_add_submodule_files(): + """Add some dummy data""" + os.chdir(submodule_dir) + _add_dummy_data() + os.chdir(repo_dir) + assert True + + +def test_add_submodule(): + """Add a submodule""" + repo.add_submodule(submodule_dir) + gbp.command_wrappers.GitCommand("commit", + ["-m 'Added submodule %s'" % submodule_dir, + "-a"])() + +def test_has_submodules(): + """Check for submodules""" + assert repo.has_submodules() + + +def test_get_submodules(): + """Check for submodules list of (name, hash)""" + submodule = repo.get_submodules("master")[0] + assert submodule[0] == './gbp_04_test_gbp_submodules_submodule' + assert len(submodule[1]) == 40 + +# vim:et:ts=4:sw=4:et:sts=4:ai:set list listchars=tab\:»·,trail\:·: |