diff options
author | 2007-09-01 17:47:42 -0700 | |
---|---|---|
committer | 2007-09-01 18:06:45 -0700 | |
commit | 0dbee1faddc65533c1d485f4b6d6693852db07c6 (patch) | |
tree | 6607cb1ea1bc9789a9b18a18500994b03e98a4f2 /gitosis/test | |
parent | Use separate temp directories for separate tests. (diff) | |
download | gitosis-gentoo-0dbee1faddc65533c1d485f4b6d6693852db07c6.tar.gz gitosis-gentoo-0dbee1faddc65533c1d485f4b6d6693852db07c6.tar.bz2 gitosis-gentoo-0dbee1faddc65533c1d485f4b6d6693852db07c6.zip |
Add utilities for fast-import, exporting repository.
Redo subprocess error handling.
Diffstat (limited to 'gitosis/test')
-rw-r--r-- | gitosis/test/test_repository.py | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/gitosis/test/test_repository.py b/gitosis/test/test_repository.py index c9fbc58..79d1561 100644 --- a/gitosis/test/test_repository.py +++ b/gitosis/test/test_repository.py @@ -1,6 +1,7 @@ from nose.tools import eq_ as eq import os +import subprocess from gitosis import repository @@ -55,3 +56,49 @@ def test_init_templates(): 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')) + +def test_export_simple(): + tmp = maketemp() + git_dir = os.path.join(tmp, 'repo.git') + repository.init(path=git_dir) + repository.fast_import( + git_dir=git_dir, + committer='John Doe <jdoe@example.com>', + commit_msg="""\ +Reverse the polarity of the neutron flow. + +Frobitz the quux and eschew obfuscation. +""", + files=[ + ('foo', 'content'), + ('bar/quux', 'another'), + ], + ) + export = os.path.join(tmp, 'export') + repository.export(git_dir=git_dir, path=export) + eq(sorted(os.listdir(export)), + sorted(['foo', 'bar'])) + eq(readFile(os.path.join(export, 'foo')), 'content') + eq(os.listdir(os.path.join(export, 'bar')), ['quux']) + eq(readFile(os.path.join(export, 'bar', 'quux')), 'another') + child = subprocess.Popen( + args=['git', 'cat-file', 'commit', 'HEAD'], + cwd=git_dir, + stdout=subprocess.PIPE, + close_fds=True, + env=dict(GIT_DIR=git_dir), + ) + got = child.stdout.read().splitlines() + returncode = child.wait() + if returncode != 0: + raise RuntimeError('git exit status %d' % returncode) + eq(got[0].split(None, 1)[0], 'tree') + eq(got[1].rsplit(None, 2)[0], + 'author John Doe <jdoe@example.com>') + eq(got[2].rsplit(None, 2)[0], + 'committer John Doe <jdoe@example.com>') + eq(got[3], '') + eq(got[4], 'Reverse the polarity of the neutron flow.') + eq(got[5], '') + eq(got[6], 'Frobitz the quux and eschew obfuscation.') + eq(got[7:], []) |