aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2011-03-18 13:23:07 +0100
committerGuido Günther <agx@sigxcpu.org>2011-03-18 13:23:07 +0100
commit7dcf49d5847b7eb2925f774aa19141e9b0847644 (patch)
tree8ef548097aa84702edac93030b95b5fff241437f /tests
parent93b4ab7a4735bb45d71f1f9a9601188e2f31b30e (diff)
Add tests for branch creation and switching
Git-Dch: Ignore
Diffstat (limited to 'tests')
-rw-r--r--tests/03_test_gbp_git.py59
1 files changed, 59 insertions, 0 deletions
diff --git a/tests/03_test_gbp_git.py b/tests/03_test_gbp_git.py
new file mode 100644
index 00000000..9c3d9369
--- /dev/null
+++ b/tests/03_test_gbp_git.py
@@ -0,0 +1,59 @@
+# vim: set fileencoding=utf-8 :
+
+import os
+import shutil
+import tempfile
+
+import gbp.git
+import gbp.command_wrappers
+
+repo = None
+repo_dir = None
+top = None
+
+def setup():
+ global repo, repo_dir, top
+
+ top = os.path.abspath(os.curdir)
+ repo_dir = os.path.join(top, 'gbp_%s_test_repo' % __name__)
+ repo = gbp.git.create_repo(repo_dir)
+ os.chdir(repo_dir)
+
+
+def teardown():
+ os.chdir(top)
+ if not os.getenv("GBP_TESTS_NOCLEAN") and repo_dir:
+ shutil.rmtree(repo_dir)
+
+
+def test_branch():
+ """Empty repos have no branch"""
+ assert repo.get_branch() == None
+
+
+def test_is_empty():
+ """Repo is still empty"""
+ assert repo.is_empty()
+
+
+def test_add_files():
+ """Add some dummy data"""
+ shutil.copy(".git/HEAD", "testfile")
+ gbp.command_wrappers.GitAdd()(['-f', '.'])
+ gbp.command_wrappers.GitCommand("commit", ["-mfoo", "-a"])()
+ assert True
+
+def test_branch_master():
+ """First branch is master"""
+ assert repo.get_branch() == "master"
+
+def test_create_branch_foo():
+ """Create branch foo"""
+ repo.create_branch("foo")
+
+def test_set_branch_foo():
+ """Switch to branch foo"""
+ repo.set_branch("foo")
+ assert repo.get_branch() == "foo"
+
+# vim:et:ts=4:sw=4:et:sts=4:ai:set list listchars=tab\:»·,trail\:·: