Indefero

Indefero Commit Details


Date:2011-04-05 19:59:26 (13 years 8 months ago)
Author:Thomas Keller
Branch:develop, feature-issue_links, feature.content-md5, feature.diff-whitespace, feature.download-md5, feature.issue-links, feature.issue-of-others, feature.issue-summary, feature.search-filter, feature.webrepos, feature.wiki-default-page, release-1.2, release-1.3
Commit:fb62061e5abea007af01c13656f4b01404d48f33
Parents: 12d3eef3d129fc53f1e09e9b326f7318a4c4e8c9
Message:Started with a unit test for the monotone interface.

Main test infrastructure is there, still lots of functionality left
for testing. Fixed a possible bug in the SCM interface already:
Pluf_HTTP_Response_NotFound needs a request instance as ctor argument,
which we don't have at this point, therefor we just throw an exception.
Changes:

File differences

src/IDF/Scm/Monotone.php
135135
136136
137137
138
138
139139
140140
141141
142142
143143
144
144
145145
146146
147147
/**
* @see IDF_Scm::getArchiveStream
*/
public function getArchiveStream($commit, $prefix='repository/')
public function getArchiveStream($commit, $prefix = null)
{
$revs = $this->_resolveSelector($commit);
// sanity: this should actually not happen, because the
// revision is validated before already
if (count($revs) == 0) {
return new Pluf_HTTP_Response_NotFound();
throw new IDF_Scm_Exception("$commit is not a valid revision");
}
return new IDF_Scm_Monotone_ZipRender($this->stdio, $revs[0]);
}
test/IDF/Scm/MonotoneTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
<?php
/* -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
# ***** BEGIN LICENSE BLOCK *****
# This file is part of InDefero, an open source project management application.
# Copyright (C) 2011 CĂ©ondo Ltd and contributors.
#
# InDefero is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# InDefero is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
# ***** END LICENSE BLOCK ***** */
class MonotoneStdioMock implements IDF_Scm_Monotone_IStdio
{
// unused
public function __construct(IDF_Project $project) {}
// unused
public function start() {}
// unused
public function stop() {}
private $outputMap = array();
public function setExpectedOutput(array $args, array $options, $output)
{
@$this->outputMap[serialize($args)][serialize($options)] = $output;
}
public function exec(array $args, array $options = array())
{
$optoutputs = @$this->outputMap[serialize($args)];
if ($optoutputs === null) {
return false;
}
return @$optoutputs[serialize($options)];
}
// unused
public function getLastOutOfBandOutput() {}
}
class IDF_Scm_Monotone_Test extends PHPUnit_Framework_TestCase
{
private $proj = null;
public function setUp()
{
$this->proj = new IDF_Project();
$this->proj->id = 1;
$this->proj->name = $this->proj->shortname = 'Test';
$this->proj->create();
$this->proj->getConf()->setVal('mtn_master_branch', 'master.branch');
}
public function tearDown()
{
$this->proj->delete();
}
public function createMock(array $args = array(), array $options = array(), $output = null)
{
$instance = new IDF_Scm_Monotone($this->proj, new MonotoneStdioMock($this->proj));
if (count($args) > 0) {
$instance->getStdio()->setExpectedOutput($args, $options, $output);
}
return $instance;
}
public function testGetStdio()
{
$instance = $this->createMock();
$this->assertNotNull($instance->getStdio());
}
public function testGetRepositorySize()
{
$this->markTestSkipped('Cannot mock real repository file');
}
public function testIsAvailable()
{
$instance = $this->createMock(array('interface_version'), array(), '13.0');
$this->assertTrue($instance->isAvailable());
$instance->getStdio()->setExpectedOutput(array('interface_version'), array(), '12.7');
$this->assertFalse($instance->isAvailable());
$instance->getStdio()->setExpectedOutput(array('interface_version'), array(), 'foo');
$this->assertFalse($instance->isAvailable());
}
public function testGetBranches()
{
$instance = $this->createMock(array('branches'), array(), "foo\nbar.baz");
$this->assertEquals(array(
'h:foo' => 'foo',
'h:bar.baz' => 'bar.baz',
), $instance->getBranches());
}
public function testGetMainBranch()
{
$instance = $this->createMock();
$this->assertEquals('master.branch', $instance->getMainBranch());
$instance->project->getConf()->setVal('mtn_master_branch', '');
$this->assertEquals('*', $instance->getMainBranch());
}
public function testGetArchiveStream()
{
$instance = $this->createMock(array('select', 'abc123'), array(), "1234567890123456789012345678901234567890\n");
$ziprender = $instance->getArchiveStream('abc123');
$this->assertTrue($ziprender instanceof IDF_Scm_Monotone_ZipRender);
$thrown = false;
try {
$ziprender = $instance->getArchiveStream('foo');
}
catch (IDF_Scm_Exception $e) {
$thrown = true;
}
$this->assertTrue($thrown);
}
public function testInBranches()
{
// returns the branches the given commit is in
}
public function testGetTags()
{
$stdio =<<<END
tag "foo-1.0"
revision [5db0a3dfb923d050d096c7c63ab23592c7ebc4c3]
signer [de84b575d5e47254393eba49dce9dc4db98ed42d]
branches "org.company.foo"
tag "foo-1.1"
revision [a4a773ecc74c1b80a03c60f57c6cc7bec85fb2cf]
signer [7fe029d85af4de40700778b9784ef488fac2c79c]
branches "org.company.foo"
tag "bar-1.0"
revision [09a00eb14482dde8876436351c6c4392b1e7f0b1]
signer [7fe029d85af4de40700778b9784ef488fac2c79c]
branches "org.company.bar" "org.company.bar.release-1.0"
END;
$instance = $this->createMock(array('tags'), array(), $stdio);
$this->assertEquals(array(
't:foo-1.0' => 'foo-1.0',
't:foo-1.1' => 'foo-1.1',
't:bar-1.0' => 'bar-1.0',
), $instance->getTags());
}
public function testInTags()
{
// returns the tags that are attached to the given commit
}
public function testGetTree()
{
// test root and sub tree fetching
}
public function testFindAuthor()
{
$this->markTestSkipped('This functionality here should reside in IDF_Scm');
}
public function testGetAnonymousAccessUrl()
{
// test the generation of the anonymous remote URL
}
public function testGetAuthAccessUrl()
{
// test the generation of the authenticated remote URL (only really visible for SSH)
}
public function testFactory()
{
$this->markTestSkipped('Cannot mock real repository');
}
public function testValidateRevision()
{
// test valid, invalid and ambigious
}
public function testDisambiguateRevision()
{
// test for array of commit objects
}
public function testGetPathInfo()
{
// return the info (creation date, last commit, et cetera) for a single file and commit
}
public function testGetFile()
{
// test cmd_only and full file fetching
}
public function testGetChanges()
{
// test retrieving the changes of a specific revision
}
public function testGetCommit()
{
// test get commit information with and without a diff text
// test multiple branches, dates, authors, aso
}
public function testGetExtraProperties()
{
// test array('parents' => array(rev1, rev2, ...)) or array() if root revision
}
public function testIsCommitLarge()
{
// test for true / false with commits with more than 100 changes
}
public function testGetChangeLog()
{
// test with no commit, empty $n
// test logging stops at unknown branches
// test logging stops at $n
}
}

Archive Download the corresponding diff file

Page rendered in 0.09099s using 13 queries.