Skip to content

Commit b006c5c

Browse files
committed
Fix test
1 parent 930bed8 commit b006c5c

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

lib/pmdtester/project.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class Project
2323
# stores the auxclasspath calculated after cloning/preparing the project
2424
attr_accessor :auxclasspath
2525

26-
def initialize(project)
26+
def initialize(project) # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
2727
@name = project.at_xpath('name').text
2828
@type = project.at_xpath('type').text
2929
@connection = project.at_xpath('connection').text

test/test_project_builder.rb

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,8 @@ def setup
1111
end
1212

1313
def test_clone
14-
expect_clone('checkstyle', 'git', 'https://github.com/checkstyle/checkstyle',
15-
'git checkout master; git reset --hard master')
16-
expect_clone('spring-framework', 'git', 'https://github.com/spring-projects/spring-framework',
17-
'git checkout v5.0.6.RELEASE; git reset --hard v5.0.6.RELEASE')
14+
expect_git_clone('checkstyle', 'https://github.com/checkstyle/checkstyle', 'master')
15+
expect_git_clone('spring-framework', 'https://github.com/spring-projects/spring-framework', 'v5.0.6.RELEASE')
1816

1917
project_builder = PmdTester::ProjectBuilder.new(@projects)
2018
project_builder.clone_projects
@@ -38,11 +36,12 @@ def test_build
3836

3937
private
4038

41-
def expect_clone(name, type, url, reset_cmd)
39+
def expect_git_clone(name, url, revision)
4240
File.stubs(:exist?).with("target/repositories/#{name}").returns(false).once
43-
PmdTester::Cmd.stubs(:execute).with("#{type} clone #{url} target/repositories/#{name}").once
41+
PmdTester::Cmd.stubs(:execute).with("git clone #{url} target/repositories/#{name} " \
42+
"--depth 1 --branch #{revision} --single-branch").once
4443
Dir.stubs(:chdir).with("target/repositories/#{name}").yields.once
45-
PmdTester::Cmd.stubs(:execute).with(reset_cmd).once
44+
PmdTester::Cmd.stubs(:execute).with("git checkout #{revision}; git reset --hard #{revision}").once
4645
end
4746

4847
def expect_build(name, build_cmd = nil, auxclasspath_cmd = nil)

0 commit comments

Comments
 (0)