diff options
author | Tommi Virtanen <tv@eagain.net> | 2007-08-30 20:00:15 -0700 |
---|---|---|
committer | Tommi Virtanen <tv@eagain.net> | 2007-08-30 20:03:17 -0700 |
commit | 5655b7f517a46fc1177a3e9007ab56b36a6d8e0c (patch) | |
tree | 07305ea591f10edd80f4ccc9f5c85e1e9d22d24e /gitosis/test/test_repository.py | |
parent | Refactor unit test writeFile/readFile helpers. (diff) | |
download | gitosis-dakkar-5655b7f517a46fc1177a3e9007ab56b36a6d8e0c.tar.gz gitosis-dakkar-5655b7f517a46fc1177a3e9007ab56b36a6d8e0c.tar.bz2 gitosis-dakkar-5655b7f517a46fc1177a3e9007ab56b36a6d8e0c.zip |
Add helper to create (bare) repositories with custom templates.
Diffstat (limited to 'gitosis/test/test_repository.py')
-rw-r--r-- | gitosis/test/test_repository.py | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/gitosis/test/test_repository.py b/gitosis/test/test_repository.py new file mode 100644 index 0000000..9b8b70c --- /dev/null +++ b/gitosis/test/test_repository.py @@ -0,0 +1,63 @@ +from nose.tools import eq_ as eq + +import os +import stat +import shutil + +from gitosis import repository + +from gitosis.test.util import mkdir, maketemp, writeFile, readFile + +def check_bare(path): + # we want it to be a bare repository + assert not os.path.exists(os.path.join(path, '.git')) + +def test_init_simple(): + tmp = maketemp() + path = os.path.join(tmp, 'repo.git') + repository.init(path) + st = os.stat(path) + assert stat.S_ISDIR(st.st_mode) + eq(stat.S_IMODE(st.st_mode), 0750) + check_bare(path) + +def test_init_exist_dir(): + tmp = maketemp() + path = os.path.join(tmp, 'repo.git') + mkdir(path) + repository.init(path) + st = os.stat(path) + assert stat.S_ISDIR(st.st_mode) + eq(stat.S_IMODE(st.st_mode), 0750) + check_bare(path) + +def test_init_exist_git(): + tmp = maketemp() + path = os.path.join(tmp, 'repo.git') + repository.init(path) + repository.init(path) + st = os.stat(path) + assert stat.S_ISDIR(st.st_mode) + eq(stat.S_IMODE(st.st_mode), 0750) + check_bare(path) + +def test_init_templates(): + tmp = maketemp() + path = os.path.join(tmp, 'repo.git') + if os.path.exists(path): + shutil.rmtree(path) + templatedir = os.path.join( + os.path.dirname(__file__), + 'mocktemplates', + ) + repository.init(path, template=templatedir) + repository.init(path) + got = readFile(os.path.join(path, 'no-confusion')) + eq(got, 'i should show up\n') + st = os.stat(os.path.join(path, 'hooks', 'post-update')) + assert stat.S_ISREG(st.st_mode) + eq('%04o'%stat.S_IMODE(st.st_mode), '%04o'%0755) + got = readFile(os.path.join(path, 'hooks', 'post-update')) + eq(got, '#!/bin/sh\n# i can override standard templates\n') + # standard templates are there, too + assert os.path.isfile(os.path.join(path, 'hooks', 'pre-rebase')) |