summaryrefslogtreecommitdiff
path: root/spec/unit/puppet/provider/vcsrepo
diff options
context:
space:
mode:
authorAaron Stone <aaron@serendipity.cx>2012-10-18 23:23:05 -0700
committerAaron Stone <aaron@serendipity.cx>2012-10-18 23:23:05 -0700
commit86594324171caf4dc96453ed3a7b56444e48b6d1 (patch)
tree258757b03c046717e093dd9063636ac0605d7928 /spec/unit/puppet/provider/vcsrepo
parentf373a8b78935b0ee1005df0ead235d76a79178c5 (diff)
downloadpuppet-vcsrepo-86594324171caf4dc96453ed3a7b56444e48b6d1.tar.gz
puppet-vcsrepo-86594324171caf4dc96453ed3a7b56444e48b6d1.tar.bz2
Update tests to match current code.
Diffstat (limited to 'spec/unit/puppet/provider/vcsrepo')
-rw-r--r--spec/unit/puppet/provider/vcsrepo/cvs_spec.rb15
-rw-r--r--spec/unit/puppet/provider/vcsrepo/git_spec.rb45
-rw-r--r--spec/unit/puppet/provider/vcsrepo/svn_spec.rb10
3 files changed, 38 insertions, 32 deletions
diff --git a/spec/unit/puppet/provider/vcsrepo/cvs_spec.rb b/spec/unit/puppet/provider/vcsrepo/cvs_spec.rb
index 7c26952..c16c7ea 100644
--- a/spec/unit/puppet/provider/vcsrepo/cvs_spec.rb
+++ b/spec/unit/puppet/provider/vcsrepo/cvs_spec.rb
@@ -6,10 +6,9 @@ describe_provider :vcsrepo, :cvs, :resource => {:path => '/tmp/vcsrepo'} do
context "with a source", :resource => {:source => ':ext:source@example.com:/foo/bar'} do
resource_with :revision do
it "should execute 'cvs checkout' and 'cvs update -r'" do
- expects_chdir
+ provider.expects(:cvs).with('-d', resource.value(:source), 'checkout', '-r', 'an-unimportant-value', '-d', 'vcsrepo', 'bar')
expects_chdir(File.dirname(resource.value(:path)))
- provider.expects(:cvs).with('-d', resource.value(:source), 'checkout', '-d', File.basename(resource.value(:path)), File.basename(resource.value(:source)))
- provider.expects(:cvs).with('update', '-r', resource.value(:revision), '.')
+ #provider.expects(:cvs).with('update', '-r', resource.value(:revision), '.')
provider.create
end
end
@@ -67,7 +66,7 @@ describe_provider :vcsrepo, :cvs, :resource => {:path => '/tmp/vcsrepo'} do
context "when CVS/Tag exists" do
before do
- @tag = 'HEAD'
+ @tag = 'TAG'
File.expects(:exist?).with(@tag_file).returns(true)
end
it "should read CVS/Tag" do
@@ -80,8 +79,8 @@ describe_provider :vcsrepo, :cvs, :resource => {:path => '/tmp/vcsrepo'} do
before do
File.expects(:exist?).with(@tag_file).returns(false)
end
- it "assumes MAIN" do
- provider.revision.should == 'MAIN'
+ it "assumes HEAD" do
+ provider.revision.should == 'HEAD'
end
end
end
@@ -91,9 +90,9 @@ describe_provider :vcsrepo, :cvs, :resource => {:path => '/tmp/vcsrepo'} do
@tag = 'SOMETAG'
end
- it "should use 'cvs update -r'" do
+ it "should use 'cvs update -dr'" do
expects_chdir
- provider.expects('cvs').with('update', '-r', @tag, '.')
+ provider.expects('cvs').with('update', '-dr', @tag, '.')
provider.revision = @tag
end
end
diff --git a/spec/unit/puppet/provider/vcsrepo/git_spec.rb b/spec/unit/puppet/provider/vcsrepo/git_spec.rb
index 1ff2a2b..240b2b8 100644
--- a/spec/unit/puppet/provider/vcsrepo/git_spec.rb
+++ b/spec/unit/puppet/provider/vcsrepo/git_spec.rb
@@ -9,9 +9,9 @@ describe_provider :vcsrepo, :git, :resource => {:path => '/tmp/vcsrepo'} do
it "should execute 'git clone' and 'git checkout -b'" do
provider.expects('git').with('clone', resource.value(:source), resource.value(:path))
expects_chdir
- provider.expects(:remote_revision_branch?).returns(true)
- provider.expects(:git).with('checkout', '-b', resource.value(:revision), '--track', "origin/#{resource.value(:revision)}")
provider.expects(:update_submodules)
+ provider.expects(:git).with('branch', '-a').returns(resource.value(:revision))
+ provider.expects(:git).with('checkout', '--force', resource.value(:revision))
provider.create
end
end
@@ -19,9 +19,9 @@ describe_provider :vcsrepo, :git, :resource => {:path => '/tmp/vcsrepo'} do
it "should execute 'git clone' and 'git reset --hard'" do
provider.expects('git').with('clone', resource.value(:source), resource.value(:path))
expects_chdir
- provider.expects(:remote_revision_branch?).returns(false)
- provider.expects('git').with('reset', '--hard', resource.value(:revision))
provider.expects(:update_submodules)
+ provider.expects(:git).with('branch', '-a').returns(resource.value(:revision))
+ provider.expects(:git).with('checkout', '--force', resource.value(:revision))
provider.create
end
end
@@ -74,8 +74,7 @@ describe_provider :vcsrepo, :git, :resource => {:path => '/tmp/vcsrepo'} do
context "when the path is not a repository" do
it "should raise an exception" do
- expects_directory?(true)
- provider.expects(:bare_exists?).returns(false)
+ provider.expects(:path_exists?).returns(true)
proc { provider.create }.should raise_error(Puppet::Error)
end
end
@@ -104,7 +103,6 @@ describe_provider :vcsrepo, :git, :resource => {:path => '/tmp/vcsrepo'} do
context "when the path is not a repository" do
it "should raise an exception" do
expects_directory?(true)
- provider.expects(:working_copy_exists?).returns(false)
proc { provider.create }.should raise_error(Puppet::Error)
end
end
@@ -129,14 +127,20 @@ describe_provider :vcsrepo, :git, :resource => {:path => '/tmp/vcsrepo'} do
context "when its SHA is not different than the current SHA" do
it "should return the ref" do
+ provider.expects(:git).with('fetch', 'origin') # FIXME
+ provider.expects(:git).with('fetch', '--tags', 'origin')
provider.expects(:git).with('rev-parse', resource.value(:revision)).returns('currentsha')
+ provider.expects(:git).with('tag', '-l').returns("Hello")
provider.revision.should == resource.value(:revision)
end
end
context "when its SHA is different than the current SHA" do
it "should return the current SHA" do
+ provider.expects(:git).with('fetch', 'origin') # FIXME
+ provider.expects(:git).with('fetch', '--tags', 'origin')
provider.expects(:git).with('rev-parse', resource.value(:revision)).returns('othersha')
+ provider.expects(:git).with('tag', '-l').returns("Hello")
provider.revision.should == 'currentsha'
end
end
@@ -146,35 +150,37 @@ describe_provider :vcsrepo, :git, :resource => {:path => '/tmp/vcsrepo'} do
context "setting the revision property" do
before do
expects_chdir
- provider.expects(:git).with('fetch', 'origin')
end
context "when it's an existing local branch", :resource => {:revision => 'feature/foo'} do
it "should use 'git fetch' and 'git reset'" do
- provider.expects(:local_revision_branch?).returns(true)
- provider.expects(:git).with('checkout', resource.value(:revision))
- provider.expects(:git).with('pull', 'origin')
provider.expects(:update_submodules)
+ provider.expects(:git).with('branch', '-a').returns(resource.value(:revision))
+ provider.expects(:git).with('checkout', '--force', resource.value(:revision))
+ provider.expects(:git).with('branch', '-a').returns(resource.value(:revision))
+ provider.expects(:git).with('reset', '--hard', "origin/#{resource.value(:revision)}")
provider.revision = resource.value(:revision)
end
end
context "when it's a remote branch", :resource => {:revision => 'only/remote'} do
it "should use 'git fetch' and 'git reset'" do
- provider.expects(:local_revision_branch?).returns(false)
- provider.expects(:remote_revision_branch?).returns(true)
- provider.expects(:git).with('checkout',
- '-b', resource.value(:revision),
- '--track', "origin/#{resource.value(:revision)}")
provider.expects(:update_submodules)
+ provider.expects(:git).with('branch', '-a').returns(resource.value(:revision))
+ provider.expects(:git).with('checkout', '--force', resource.value(:revision))
+ provider.expects(:git).with('branch', '-a').returns(resource.value(:revision))
+ provider.expects(:git).with('reset', '--hard', "origin/#{resource.value(:revision)}")
provider.revision = resource.value(:revision)
end
end
context "when it's a commit or tag", :resource => {:revision => 'a-commit-or-tag'} do
it "should use 'git fetch' and 'git reset'" do
- provider.expects(:local_revision_branch?).returns(false)
- provider.expects(:remote_revision_branch?).returns(false)
- provider.expects(:git).with('reset', '--hard', resource.value(:revision))
+ provider.expects(:git).with('branch', '-a').returns(fixture(:git_branch_a))
+ provider.expects(:git).with('checkout', '--force', resource.value(:revision))
+ provider.expects(:git).with('branch', '-a').returns(fixture(:git_branch_a))
provider.expects(:git).with('submodule', 'init')
provider.expects(:git).with('submodule', 'update')
+ provider.expects(:git).with('branch', '-a').returns(fixture(:git_branch_a))
+ provider.expects(:git).with('submodule', 'foreach', 'git', 'submodule', 'init')
+ provider.expects(:git).with('submodule', 'foreach', 'git', 'submodule', 'update')
provider.revision = resource.value(:revision)
end
end
@@ -183,6 +189,7 @@ describe_provider :vcsrepo, :git, :resource => {:path => '/tmp/vcsrepo'} do
context "updating references" do
it "should use 'git fetch --tags'" do
expects_chdir
+ provider.expects(:git).with('fetch', 'origin')
provider.expects(:git).with('fetch', '--tags', 'origin')
provider.update_references
end
diff --git a/spec/unit/puppet/provider/vcsrepo/svn_spec.rb b/spec/unit/puppet/provider/vcsrepo/svn_spec.rb
index 042554c..5c27818 100644
--- a/spec/unit/puppet/provider/vcsrepo/svn_spec.rb
+++ b/spec/unit/puppet/provider/vcsrepo/svn_spec.rb
@@ -6,7 +6,7 @@ describe_provider :vcsrepo, :svn, :resource => {:path => '/tmp/vcsrepo'} do
resource_with :source do
resource_with :revision do
it "should execute 'svn checkout' with a revision" do
- provider.expects(:svn).with('checkout', '-r',
+ provider.expects(:svn).with('--non-interactive', 'checkout', '-r',
resource.value(:revision),
resource.value(:source),
resource.value(:path))
@@ -15,7 +15,7 @@ describe_provider :vcsrepo, :svn, :resource => {:path => '/tmp/vcsrepo'} do
end
resource_without :revision do
it "should just execute 'svn checkout' without a revision" do
- provider.expects(:svn).with('checkout',
+ provider.expects(:svn).with('--non-interactive', 'checkout',
resource.value(:source),
resource.value(:path))
provider.create
@@ -56,11 +56,11 @@ describe_provider :vcsrepo, :svn, :resource => {:path => '/tmp/vcsrepo'} do
describe "checking the revision property" do
before do
- provider.expects('svn').with('info').returns(fixture(:svn_info))
+ provider.expects('svn').with('--non-interactive', 'info').returns(fixture(:svn_info))
end
it "should use 'svn info'" do
expects_chdir
- provider.revision.should == '4'
+ provider.revision.should == '3' # From 'Last Changed Rev', not 'Revision'
end
end
@@ -70,7 +70,7 @@ describe_provider :vcsrepo, :svn, :resource => {:path => '/tmp/vcsrepo'} do
end
it "should use 'svn update'" do
expects_chdir
- provider.expects('svn').with('update', '-r', @revision)
+ provider.expects('svn').with('--non-interactive', 'update', '-r', @revision)
provider.revision = @revision
end
end