/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to tests/test_blackbox.py

More work on roundtrip push support.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""Black-box tests for bzr-git."""
18
18
 
 
19
from dulwich.repo import (
 
20
    Repo as GitRepo,
 
21
    )
 
22
 
19
23
import os
20
24
 
21
 
from bzrlib.tests import KnownFailure
 
25
from bzrlib.bzrdir import (
 
26
    BzrDir,
 
27
    )
 
28
 
22
29
from bzrlib.tests.blackbox import ExternalBase
23
30
 
24
31
from bzrlib.plugins.git import (
30
37
 
31
38
    def simple_commit(self):
32
39
        # Create a git repository with a revision.
33
 
        tests.run_git('init')
 
40
        repo = GitRepo.init(self.test_dir)
34
41
        builder = tests.GitBranchBuilder()
35
42
        builder.set_file('a', 'text for a\n', False)
36
 
        builder.commit('Joe Foo <joe@foo.com>', u'<The commit message>')
37
 
        builder.finish()
 
43
        r1 = builder.commit('Joe Foo <joe@foo.com>', u'<The commit message>')
 
44
        return repo, builder.finish()[r1]
 
45
 
 
46
    def test_nick(self):
 
47
        GitRepo.init(self.test_dir)
 
48
        dir = BzrDir.open(self.test_dir)
 
49
        dir.create_branch()
 
50
        output, error = self.run_bzr(['nick'])
 
51
        self.assertEquals("HEAD\n", output)
38
52
 
39
53
    def test_info(self):
40
54
        self.simple_commit()
41
55
        output, error = self.run_bzr(['info'])
42
56
        self.assertEqual(error, '')
43
 
        self.assertTrue("Repository branch (format: git)" in output)
 
57
        self.assertTrue("Standalone tree (format: git)" in output)
44
58
 
45
59
    def test_branch(self):
46
60
        os.mkdir("gitbranch")
47
 
        os.chdir("gitbranch")
48
 
        tests.run_git('init')
 
61
        GitRepo.init(os.path.join(self.test_dir, "gitbranch"))
 
62
        os.chdir('gitbranch')
49
63
        builder = tests.GitBranchBuilder()
50
64
        builder.set_file('a', 'text for a\n', False)
51
65
        builder.commit('Joe Foo <joe@foo.com>', u'<The commit message>')
52
66
        builder.finish()
 
67
        os.chdir('..')
53
68
 
54
 
        os.chdir("..")
55
69
        output, error = self.run_bzr(['branch', 'gitbranch', 'bzrbranch'])
56
70
        self.assertEqual(error, 'Branched 1 revision(s).\n')
57
71
 
69
83
 
70
84
        output, error = self.run_bzr(['info', '-v'])
71
85
        self.assertEqual(error, '')
72
 
        self.assertTrue("Repository tree (format: git)" in output)
 
86
        self.assertTrue("Standalone tree (format: git)" in output)
73
87
        self.assertTrue("control: Local Git Repository" in output)
74
88
        self.assertTrue("branch: Git Branch" in output)
75
89
        self.assertTrue("repository: Git Repository" in output)
76
90
 
 
91
    def test_push(self):
 
92
        os.mkdir("bla")
 
93
        GitRepo.init(os.path.join(self.test_dir, "bla"))
 
94
        self.run_bzr(['init', 'foo'])
 
95
        self.run_bzr(['commit', '--unchanged', '-m', 'bla', 'foo'])
 
96
        output, error = self.run_bzr(['push', '-d', 'foo', 'bla'])
 
97
        self.assertEquals("", output)
 
98
        self.assertTrue(error.endswith("Created new branch.\n"))
 
99
 
77
100
    def test_log(self):
78
101
        # Smoke test for "bzr log" in a git repository.
79
102
        self.simple_commit()
93
116
        output, error = self.run_bzr(['log', '-v'])
94
117
 
95
118
    def test_tags(self):
96
 
        self.simple_commit()
97
 
 
98
 
        tests.run_git("tag", "foo")
 
119
        git_repo, commit_sha1 = self.simple_commit()
 
120
        git_repo.refs["refs/tags/foo"] = commit_sha1
99
121
 
100
122
        output, error = self.run_bzr(['tags'])
101
123
        self.assertEquals(error, '')
109
131
        self.assertEquals(error, '')
110
132
        self.assertEquals(output, 'Created tag bar.\n')
111
133
 
 
134
    def test_init_repo(self):
 
135
        output, error = self.run_bzr(["init-repo", "--git", "bla.git"])
 
136
        self.assertEquals(error, '')
 
137
        self.assertEquals(output, 'Unshared repository with trees (format: git)\nLocation:\n  repository: bla.git\n')
 
138