bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
0.200.262
by Jelmer Vernooij
Add tests for GitShaMap. |
1 |
# Copyright (C) 2009 Jelmer Vernooij <jelmer@samba.org>
|
2 |
#
|
|
3 |
# This program is free software; you can redistribute it and/or modify
|
|
4 |
# it under the terms of the GNU General Public License as published by
|
|
5 |
# the Free Software Foundation; either version 2 of the License, or
|
|
6 |
# (at your option) any later version.
|
|
7 |
#
|
|
8 |
# This program is distributed in the hope that it will be useful,
|
|
9 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11 |
# GNU General Public License for more details.
|
|
12 |
#
|
|
13 |
# You should have received a copy of the GNU General Public License
|
|
14 |
# along with this program; if not, write to the Free Software
|
|
15 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
16 |
||
17 |
"""Tests for GitShaMap."""
|
|
18 |
||
|
0.200.475
by Jelmer Vernooij
Add Tdb database backend. |
19 |
import os |
20 |
||
21 |
from bzrlib.tests import ( |
|
22 |
TestCase, |
|
23 |
TestCaseInTempDir, |
|
24 |
UnavailableFeature, |
|
25 |
)
|
|
|
0.200.262
by Jelmer Vernooij
Add tests for GitShaMap. |
26 |
|
27 |
from bzrlib.plugins.git.shamap import ( |
|
28 |
DictGitShaMap, |
|
29 |
SqliteGitShaMap, |
|
|
0.200.475
by Jelmer Vernooij
Add Tdb database backend. |
30 |
TdbGitShaMap, |
|
0.200.262
by Jelmer Vernooij
Add tests for GitShaMap. |
31 |
)
|
32 |
||
33 |
class TestGitShaMap: |
|
34 |
||
35 |
def test_commit(self): |
|
|
0.200.687
by Jelmer Vernooij
Use start_write_group() / commit_write_group() mechanism when creating git SHA maps. |
36 |
self.map.start_write_group() |
37 |
self.map.add_entry("5686645d49063c73d35436192dfc9a160c672301", |
|
|
0.200.262
by Jelmer Vernooij
Add tests for GitShaMap. |
38 |
"commit", ("myrevid", "cc9462f7f8263ef5adfbeff2fb936bb36b504cba")) |
|
0.200.687
by Jelmer Vernooij
Use start_write_group() / commit_write_group() mechanism when creating git SHA maps. |
39 |
self.map.commit_write_group() |
|
0.200.262
by Jelmer Vernooij
Add tests for GitShaMap. |
40 |
self.assertEquals( |
41 |
("commit", ("myrevid", "cc9462f7f8263ef5adfbeff2fb936bb36b504cba")), |
|
42 |
self.map.lookup_git_sha("5686645d49063c73d35436192dfc9a160c672301")) |
|
43 |
||
44 |
def test_lookup_notfound(self): |
|
|
0.200.687
by Jelmer Vernooij
Use start_write_group() / commit_write_group() mechanism when creating git SHA maps. |
45 |
self.assertRaises(KeyError, |
|
0.200.262
by Jelmer Vernooij
Add tests for GitShaMap. |
46 |
self.map.lookup_git_sha, "5686645d49063c73d35436192dfc9a160c672301") |
|
0.200.687
by Jelmer Vernooij
Use start_write_group() / commit_write_group() mechanism when creating git SHA maps. |
47 |
|
|
0.200.262
by Jelmer Vernooij
Add tests for GitShaMap. |
48 |
def test_blob(self): |
|
0.200.477
by Jelmer Vernooij
More tests for sha maps, fix cache misses in tdb. |
49 |
thesha = "5686645d49063c73d35436192dfc9a160c672301" |
|
0.200.687
by Jelmer Vernooij
Use start_write_group() / commit_write_group() mechanism when creating git SHA maps. |
50 |
self.map.start_write_group() |
|
0.200.477
by Jelmer Vernooij
More tests for sha maps, fix cache misses in tdb. |
51 |
self.map.add_entry(thesha, "blob", ("myfileid", "myrevid")) |
|
0.200.687
by Jelmer Vernooij
Use start_write_group() / commit_write_group() mechanism when creating git SHA maps. |
52 |
self.map.commit_write_group() |
|
0.200.262
by Jelmer Vernooij
Add tests for GitShaMap. |
53 |
self.assertEquals( |
54 |
("blob", ("myfileid", "myrevid")), |
|
|
0.200.477
by Jelmer Vernooij
More tests for sha maps, fix cache misses in tdb. |
55 |
self.map.lookup_git_sha(thesha)) |
56 |
self.assertEquals(thesha, self.map.lookup_blob("myfileid", "myrevid")) |
|
|
0.200.262
by Jelmer Vernooij
Add tests for GitShaMap. |
57 |
|
58 |
def test_tree(self): |
|
|
0.200.477
by Jelmer Vernooij
More tests for sha maps, fix cache misses in tdb. |
59 |
thesha = "5686645d49063c73d35436192dfc9a160c672301" |
|
0.200.687
by Jelmer Vernooij
Use start_write_group() / commit_write_group() mechanism when creating git SHA maps. |
60 |
self.map.start_write_group() |
61 |
self.map.add_entry(thesha, |
|
|
0.200.262
by Jelmer Vernooij
Add tests for GitShaMap. |
62 |
"tree", ("somepath", "myrevid")) |
|
0.200.687
by Jelmer Vernooij
Use start_write_group() / commit_write_group() mechanism when creating git SHA maps. |
63 |
self.map.commit_write_group() |
|
0.200.262
by Jelmer Vernooij
Add tests for GitShaMap. |
64 |
self.assertEquals( |
65 |
("tree", ("somepath", "myrevid")), |
|
|
0.200.477
by Jelmer Vernooij
More tests for sha maps, fix cache misses in tdb. |
66 |
self.map.lookup_git_sha(thesha)) |
67 |
self.assertEquals(thesha, self.map.lookup_tree("somepath", "myrevid")) |
|
|
0.200.262
by Jelmer Vernooij
Add tests for GitShaMap. |
68 |
|
69 |
def test_revids(self): |
|
|
0.200.687
by Jelmer Vernooij
Use start_write_group() / commit_write_group() mechanism when creating git SHA maps. |
70 |
self.map.start_write_group() |
71 |
self.map.add_entry("5686645d49063c73d35436192dfc9a160c672301", |
|
|
0.200.262
by Jelmer Vernooij
Add tests for GitShaMap. |
72 |
"commit", ("myrevid", "cc9462f7f8263ef5adfbeff2fb936bb36b504cba")) |
|
0.200.687
by Jelmer Vernooij
Use start_write_group() / commit_write_group() mechanism when creating git SHA maps. |
73 |
self.map.commit_write_group() |
|
0.200.262
by Jelmer Vernooij
Add tests for GitShaMap. |
74 |
self.assertEquals(["myrevid"], list(self.map.revids())) |
75 |
||
76 |
||
77 |
class DictGitShaMapTests(TestCase,TestGitShaMap): |
|
78 |
||
79 |
def setUp(self): |
|
|
0.200.280
by Jelmer Vernooij
Support bzr.dev. |
80 |
TestCase.setUp(self) |
|
0.200.262
by Jelmer Vernooij
Add tests for GitShaMap. |
81 |
self.map = DictGitShaMap() |
82 |
||
83 |
||
84 |
class SqliteGitShaMapTests(TestCase,TestGitShaMap): |
|
85 |
||
86 |
def setUp(self): |
|
|
0.200.280
by Jelmer Vernooij
Support bzr.dev. |
87 |
TestCase.setUp(self) |
|
0.200.262
by Jelmer Vernooij
Add tests for GitShaMap. |
88 |
self.map = SqliteGitShaMap() |
89 |
||
|
0.200.475
by Jelmer Vernooij
Add Tdb database backend. |
90 |
|
91 |
class TdbGitShaMapTests(TestCaseInTempDir,TestGitShaMap): |
|
92 |
||
93 |
def setUp(self): |
|
94 |
TestCaseInTempDir.setUp(self) |
|
95 |
try: |
|
96 |
self.map = TdbGitShaMap(os.path.join(self.test_dir, 'foo.tdb')) |
|
97 |
except ImportError: |
|
98 |
raise UnavailableFeature("Missing tdb") |