Differential D14241 Diff 34410 src/applications/diffusion/protocol/__tests__/DiffusionMercurialWireProtocolTests.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/diffusion/protocol/__tests__/DiffusionMercurialWireProtocolTests.php
- This file was added.
<?php | |||||
final class DiffusionMercurialWireProtocolTests extends PhabricatorTestCase { | |||||
public function testFilteringBundle2Capability() { | |||||
// this was the result of running 'capabilities' over | |||||
// `hg serve --stdio` on my systems with Mercurial 3.5.1, 2.6.2 | |||||
$capabilities_with_bundle2_hg_351 = | |||||
'lookup changegroupsubset branchmap pushkey '. | |||||
'known getbundle unbundlehash batch stream '. | |||||
'bundle2=HG20%0Achangegroup%3D01%2C02%0Adigests%3Dmd5%2Csha1%2Csha512'. | |||||
'%0Aerror%3Dabort%2Cunsupportedcontent%2Cpushraced%2Cpushkey%0A'. | |||||
'hgtagsfnodes%0Alistkeys%0Apushkey%0Aremote-changegroup%3Dhttp%2Chttps '. | |||||
'unbundle=HG10GZ,HG10BZ,HG10UN httpheader=1024'; | |||||
epriestley: Consider moving the strings into this method, since it's unlikely that other tests will need to… | |||||
Not Done Inline ActionsI'll restructure the test in that fashion, it definitely makes more sense. I wasn't sure how best to place the strings - I think I was trying to do something similar to static constants. cspeckmim: I'll restructure the test in that fashion, it definitely makes more sense. I wasn't sure how… | |||||
$capabilities_without_bundle2_hg_351 = | |||||
'lookup changegroupsubset branchmap pushkey '. | |||||
'known getbundle unbundlehash batch stream '. | |||||
'unbundle=HG10GZ,HG10BZ,HG10UN httpheader=1024'; | |||||
$capabilities_hg_262 = | |||||
'lookup changegroupsubset branchmap pushkey '. | |||||
'known getbundle unbundlehash batch stream '. | |||||
'unbundle=HG10GZ,HG10BZ,HG10UN httpheader=1024 largefiles=serve'; | |||||
$cases = array( | |||||
array( | |||||
'name' => pht('Filter bundle2 from Mercurial 3.5.1'), | |||||
'input' => $capabilities_with_bundle2_hg_351, | |||||
'expect' => $capabilities_without_bundle2_hg_351, | |||||
), | |||||
array( | |||||
'name' => pht('Filter bundle does not affect Mercurial 2.6.2'), | |||||
'input' => $capabilities_hg_262, | |||||
'expect' => $capabilities_hg_262, | |||||
), | |||||
); | |||||
foreach ($cases as $case) { | |||||
$actual = DiffusionMercurialWireProtocol::filterBundle2Capability( | |||||
$case['input']); | |||||
$this->assertEqual($case['expect'], $actual, $case['name']); | |||||
} | |||||
} | |||||
} |
Consider moving the strings into this method, since it's unlikely that other tests will need to access them. The most standard format in this codebase would be something like:
Then:
This makes it a little easier to add more cases later, too.