mirror of
https://github.com/sstent/Vagrant_Openstack.git
synced 2026-01-25 22:52:45 +00:00
adding fake driver
This commit is contained in:
@@ -1,90 +1,90 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe_provider :vcsrepo, :bzr, :resource => {:path => '/tmp/vcsrepo'} do
|
||||
|
||||
describe 'creating' do
|
||||
resource_with :source do
|
||||
resource_with :revision do
|
||||
it "should execute 'bzr clone -r' with the revision" do
|
||||
provider.expects(:bzr).with('branch', '-r', resource.value(:revision), resource.value(:source), resource.value(:path))
|
||||
provider.create
|
||||
end
|
||||
end
|
||||
resource_without :revision do
|
||||
it "should just execute 'bzr clone' without a revision" do
|
||||
provider.expects(:bzr).with('branch', resource.value(:source), resource.value(:path))
|
||||
provider.create
|
||||
end
|
||||
end
|
||||
end
|
||||
resource_without :source do
|
||||
it "should execute 'bzr init'" do
|
||||
provider.expects(:bzr).with('init', resource.value(:path))
|
||||
provider.create
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'destroying' do
|
||||
it "it should remove the directory" do
|
||||
expects_rm_rf
|
||||
provider.destroy
|
||||
end
|
||||
end
|
||||
|
||||
describe "checking existence" do
|
||||
it "should check for the directory" do
|
||||
expects_directory?(true, File.join(resource.value(:path), '.bzr'))
|
||||
provider.exists?
|
||||
end
|
||||
end
|
||||
|
||||
describe "checking the revision property" do
|
||||
before do
|
||||
expects_chdir
|
||||
provider.expects(:bzr).with('version-info').returns(fixture(:bzr_version_info))
|
||||
@current_revid = 'menesis@pov.lt-20100309191856-4wmfqzc803fj300x'
|
||||
end
|
||||
context "when given a non-revid as the resource revision", :resource => {:revision => '2634'} do
|
||||
context "when its revid is not different than the current revid" do
|
||||
before do
|
||||
provider.expects(:bzr).with('revision-info', resource.value(:revision)).returns("#{resource.value(:revision)} menesis@pov.lt-20100309191856-4wmfqzc803fj300x\n")
|
||||
end
|
||||
it "should return the ref" do
|
||||
provider.revision.should == resource.value(:revision)
|
||||
end
|
||||
end
|
||||
context "when its revid is different than the current revid", :resource => {:revision => '2636'} do
|
||||
it "should return the current revid" do
|
||||
provider.expects(:bzr).with('revision-info', resource.value(:revision)).returns("2635 foo\n")
|
||||
provider.revision.should == @current_revid
|
||||
end
|
||||
end
|
||||
end
|
||||
context "when given a revid as the resource revision" do
|
||||
context "when it is the same as the current revid", :resource => {:revision => 'menesis@pov.lt-20100309191856-4wmfqzc803fj300x'} do
|
||||
before do
|
||||
provider.expects(:bzr).with('revision-info', resource.value(:revision)).returns("1234 #{resource.value(:revision)}\n")
|
||||
end
|
||||
it "should return it" do
|
||||
provider.revision.should == resource.value(:revision)
|
||||
end
|
||||
end
|
||||
context "when it is not the same as the current revid", :resource => {:revision => 'menesis@pov.lt-20100309191856-4wmfqzc803fj300y'} do
|
||||
it "should return the current revid" do
|
||||
provider.expects(:bzr).with('revision-info', resource.value(:revision)).returns("2636 foo\n")
|
||||
provider.revision.should == @current_revid
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "setting the revision property" do
|
||||
it "should use 'bzr update -r' with the revision" do
|
||||
expects_chdir
|
||||
provider.expects(:bzr).with('update', '-r', 'somerev')
|
||||
provider.revision = 'somerev'
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
require 'spec_helper'
|
||||
|
||||
describe_provider :vcsrepo, :bzr, :resource => {:path => '/tmp/vcsrepo'} do
|
||||
|
||||
describe 'creating' do
|
||||
resource_with :source do
|
||||
resource_with :revision do
|
||||
it "should execute 'bzr clone -r' with the revision" do
|
||||
provider.expects(:bzr).with('branch', '-r', resource.value(:revision), resource.value(:source), resource.value(:path))
|
||||
provider.create
|
||||
end
|
||||
end
|
||||
resource_without :revision do
|
||||
it "should just execute 'bzr clone' without a revision" do
|
||||
provider.expects(:bzr).with('branch', resource.value(:source), resource.value(:path))
|
||||
provider.create
|
||||
end
|
||||
end
|
||||
end
|
||||
resource_without :source do
|
||||
it "should execute 'bzr init'" do
|
||||
provider.expects(:bzr).with('init', resource.value(:path))
|
||||
provider.create
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'destroying' do
|
||||
it "it should remove the directory" do
|
||||
expects_rm_rf
|
||||
provider.destroy
|
||||
end
|
||||
end
|
||||
|
||||
describe "checking existence" do
|
||||
it "should check for the directory" do
|
||||
expects_directory?(true, File.join(resource.value(:path), '.bzr'))
|
||||
provider.exists?
|
||||
end
|
||||
end
|
||||
|
||||
describe "checking the revision property" do
|
||||
before do
|
||||
expects_chdir
|
||||
provider.expects(:bzr).with('version-info').returns(fixture(:bzr_version_info))
|
||||
@current_revid = 'menesis@pov.lt-20100309191856-4wmfqzc803fj300x'
|
||||
end
|
||||
context "when given a non-revid as the resource revision", :resource => {:revision => '2634'} do
|
||||
context "when its revid is not different than the current revid" do
|
||||
before do
|
||||
provider.expects(:bzr).with('revision-info', resource.value(:revision)).returns("#{resource.value(:revision)} menesis@pov.lt-20100309191856-4wmfqzc803fj300x\n")
|
||||
end
|
||||
it "should return the ref" do
|
||||
provider.revision.should == resource.value(:revision)
|
||||
end
|
||||
end
|
||||
context "when its revid is different than the current revid", :resource => {:revision => '2636'} do
|
||||
it "should return the current revid" do
|
||||
provider.expects(:bzr).with('revision-info', resource.value(:revision)).returns("2635 foo\n")
|
||||
provider.revision.should == @current_revid
|
||||
end
|
||||
end
|
||||
end
|
||||
context "when given a revid as the resource revision" do
|
||||
context "when it is the same as the current revid", :resource => {:revision => 'menesis@pov.lt-20100309191856-4wmfqzc803fj300x'} do
|
||||
before do
|
||||
provider.expects(:bzr).with('revision-info', resource.value(:revision)).returns("1234 #{resource.value(:revision)}\n")
|
||||
end
|
||||
it "should return it" do
|
||||
provider.revision.should == resource.value(:revision)
|
||||
end
|
||||
end
|
||||
context "when it is not the same as the current revid", :resource => {:revision => 'menesis@pov.lt-20100309191856-4wmfqzc803fj300y'} do
|
||||
it "should return the current revid" do
|
||||
provider.expects(:bzr).with('revision-info', resource.value(:revision)).returns("2636 foo\n")
|
||||
provider.revision.should == @current_revid
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "setting the revision property" do
|
||||
it "should use 'bzr update -r' with the revision" do
|
||||
expects_chdir
|
||||
provider.expects(:bzr).with('update', '-r', 'somerev')
|
||||
provider.revision = 'somerev'
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,100 +1,100 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe_provider :vcsrepo, :cvs, :resource => {:path => '/tmp/vcsrepo'} do
|
||||
|
||||
describe 'creating' 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
|
||||
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('update', '-r', resource.value(:revision), '.')
|
||||
provider.create
|
||||
end
|
||||
end
|
||||
|
||||
resource_without :revision do
|
||||
it "should just execute 'cvs checkout' without a revision" do
|
||||
provider.expects(:cvs).with('-d', resource.value(:source), 'checkout', '-d', File.basename(resource.value(:path)), File.basename(resource.value(:source)))
|
||||
provider.create
|
||||
end
|
||||
end
|
||||
|
||||
context "with a compression", :resource => {:compression => '3'} do
|
||||
it "should just execute 'cvs checkout' without a revision" do
|
||||
provider.expects(:cvs).with('-d', resource.value(:source), '-z', '3', 'checkout', '-d', File.basename(resource.value(:path)), File.basename(resource.value(:source)))
|
||||
provider.create
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "when a source is not given" do
|
||||
it "should execute 'cvs init'" do
|
||||
provider.expects(:cvs).with('-d', resource.value(:path), 'init')
|
||||
provider.create
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'destroying' do
|
||||
it "it should remove the directory" do
|
||||
expects_rm_rf
|
||||
provider.destroy
|
||||
end
|
||||
end
|
||||
|
||||
describe "checking existence" do
|
||||
resource_with :source do
|
||||
it "should check for the CVS directory" do
|
||||
File.expects(:directory?).with(File.join(resource.value(:path), 'CVS'))
|
||||
provider.exists?
|
||||
end
|
||||
end
|
||||
|
||||
resource_without :source do
|
||||
it "should check for the CVSROOT directory" do
|
||||
File.expects(:directory?).with(File.join(resource.value(:path), 'CVSROOT'))
|
||||
provider.exists?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "checking the revision property" do
|
||||
before do
|
||||
@tag_file = File.join(resource.value(:path), 'CVS', 'Tag')
|
||||
end
|
||||
|
||||
context "when CVS/Tag exists" do
|
||||
before do
|
||||
@tag = 'TAG'
|
||||
File.expects(:exist?).with(@tag_file).returns(true)
|
||||
end
|
||||
it "should read CVS/Tag" do
|
||||
File.expects(:read).with(@tag_file).returns("T#{@tag}")
|
||||
provider.revision.should == @tag
|
||||
end
|
||||
end
|
||||
|
||||
context "when CVS/Tag does not exist" do
|
||||
before do
|
||||
File.expects(:exist?).with(@tag_file).returns(false)
|
||||
end
|
||||
it "assumes HEAD" do
|
||||
provider.revision.should == 'HEAD'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "when setting the revision property" do
|
||||
before do
|
||||
@tag = 'SOMETAG'
|
||||
end
|
||||
|
||||
it "should use 'cvs update -dr'" do
|
||||
expects_chdir
|
||||
provider.expects(:cvs).with('update', '-dr', @tag, '.')
|
||||
provider.revision = @tag
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
require 'spec_helper'
|
||||
|
||||
describe_provider :vcsrepo, :cvs, :resource => {:path => '/tmp/vcsrepo'} do
|
||||
|
||||
describe 'creating' 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
|
||||
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('update', '-r', resource.value(:revision), '.')
|
||||
provider.create
|
||||
end
|
||||
end
|
||||
|
||||
resource_without :revision do
|
||||
it "should just execute 'cvs checkout' without a revision" do
|
||||
provider.expects(:cvs).with('-d', resource.value(:source), 'checkout', '-d', File.basename(resource.value(:path)), File.basename(resource.value(:source)))
|
||||
provider.create
|
||||
end
|
||||
end
|
||||
|
||||
context "with a compression", :resource => {:compression => '3'} do
|
||||
it "should just execute 'cvs checkout' without a revision" do
|
||||
provider.expects(:cvs).with('-d', resource.value(:source), '-z', '3', 'checkout', '-d', File.basename(resource.value(:path)), File.basename(resource.value(:source)))
|
||||
provider.create
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "when a source is not given" do
|
||||
it "should execute 'cvs init'" do
|
||||
provider.expects(:cvs).with('-d', resource.value(:path), 'init')
|
||||
provider.create
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'destroying' do
|
||||
it "it should remove the directory" do
|
||||
expects_rm_rf
|
||||
provider.destroy
|
||||
end
|
||||
end
|
||||
|
||||
describe "checking existence" do
|
||||
resource_with :source do
|
||||
it "should check for the CVS directory" do
|
||||
File.expects(:directory?).with(File.join(resource.value(:path), 'CVS'))
|
||||
provider.exists?
|
||||
end
|
||||
end
|
||||
|
||||
resource_without :source do
|
||||
it "should check for the CVSROOT directory" do
|
||||
File.expects(:directory?).with(File.join(resource.value(:path), 'CVSROOT'))
|
||||
provider.exists?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "checking the revision property" do
|
||||
before do
|
||||
@tag_file = File.join(resource.value(:path), 'CVS', 'Tag')
|
||||
end
|
||||
|
||||
context "when CVS/Tag exists" do
|
||||
before do
|
||||
@tag = 'TAG'
|
||||
File.expects(:exist?).with(@tag_file).returns(true)
|
||||
end
|
||||
it "should read CVS/Tag" do
|
||||
File.expects(:read).with(@tag_file).returns("T#{@tag}")
|
||||
provider.revision.should == @tag
|
||||
end
|
||||
end
|
||||
|
||||
context "when CVS/Tag does not exist" do
|
||||
before do
|
||||
File.expects(:exist?).with(@tag_file).returns(false)
|
||||
end
|
||||
it "assumes HEAD" do
|
||||
provider.revision.should == 'HEAD'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "when setting the revision property" do
|
||||
before do
|
||||
@tag = 'SOMETAG'
|
||||
end
|
||||
|
||||
it "should use 'cvs update -dr'" do
|
||||
expects_chdir
|
||||
provider.expects(:cvs).with('update', '-dr', @tag, '.')
|
||||
provider.revision = @tag
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe_provider :vcsrepo, :dummy, :resource => {:path => '/tmp/vcsrepo'} do
|
||||
|
||||
context 'dummy' do
|
||||
resource_with :source do
|
||||
resource_with :ensure => :present do
|
||||
context "with nothing doing", :resource => {:revision => 'foo'} do
|
||||
it "should raise an exception" do
|
||||
proc { provider.working_copy_exists? }.should raise_error(RuntimeError)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
require 'spec_helper'
|
||||
|
||||
describe_provider :vcsrepo, :dummy, :resource => {:path => '/tmp/vcsrepo'} do
|
||||
|
||||
context 'dummy' do
|
||||
resource_with :source do
|
||||
resource_with :ensure => :present do
|
||||
context "with nothing doing", :resource => {:revision => 'foo'} do
|
||||
it "should raise an exception" do
|
||||
proc { provider.working_copy_exists? }.should raise_error(RuntimeError)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,248 +1,248 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe_provider :vcsrepo, :git, :resource => {:path => '/tmp/vcsrepo'} do
|
||||
|
||||
context 'creating' do
|
||||
resource_with :source do
|
||||
resource_with :ensure => :present do
|
||||
context "with a revision that is a remote branch", :resource => {:revision => 'only/remote'} do
|
||||
it "should execute 'git clone' and 'git checkout -b'" do
|
||||
provider.expects(:git).with('clone', resource.value(:source), resource.value(:path))
|
||||
expects_chdir('/')
|
||||
expects_chdir
|
||||
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
|
||||
context "with a revision that is not a remote branch", :resource => {:revision => 'a-commit-or-tag'} do
|
||||
it "should execute 'git clone' and 'git reset --hard'" do
|
||||
provider.expects(:git).with('clone', resource.value(:source), resource.value(:path))
|
||||
expects_chdir('/')
|
||||
expects_chdir
|
||||
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
|
||||
resource_without :revision do
|
||||
it "should execute 'git clone' and submodule commands" do
|
||||
provider.expects(:git).with('clone', resource.value(:source), resource.value(:path))
|
||||
provider.expects(:update_submodules)
|
||||
provider.create
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
resource_with :ensure => :bare do
|
||||
resource_with :revision do
|
||||
it "should just execute 'git clone --bare'" do
|
||||
provider.expects(:git).with('clone', '--bare', resource.value(:source), resource.value(:path))
|
||||
provider.create
|
||||
end
|
||||
end
|
||||
|
||||
resource_without :revision do
|
||||
it "should just execute 'git clone --bare'" do
|
||||
provider.expects(:git).with('clone', '--bare', resource.value(:source), resource.value(:path))
|
||||
provider.create
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "when a source is not given" do
|
||||
resource_with :ensure => :present do
|
||||
context "when the path does not exist" do
|
||||
it "should execute 'git init'" do
|
||||
expects_mkdir
|
||||
expects_chdir
|
||||
expects_directory?(false)
|
||||
provider.expects(:bare_exists?).returns(false)
|
||||
provider.expects(:git).with('init')
|
||||
provider.create
|
||||
end
|
||||
end
|
||||
|
||||
context "when the path is a bare repository" do
|
||||
it "should convert it to a working copy" do
|
||||
provider.expects(:bare_exists?).returns(true)
|
||||
provider.expects(:convert_bare_to_working_copy)
|
||||
provider.create
|
||||
end
|
||||
end
|
||||
|
||||
context "when the path is not a repository" do
|
||||
it "should raise an exception" do
|
||||
provider.expects(:path_exists?).returns(true)
|
||||
proc { provider.create }.should raise_error(Puppet::Error)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
resource_with :ensure => :bare do
|
||||
context "when the path does not exist" do
|
||||
it "should execute 'git init --bare'" do
|
||||
expects_chdir
|
||||
expects_mkdir
|
||||
expects_directory?(false)
|
||||
provider.expects(:working_copy_exists?).returns(false)
|
||||
provider.expects(:git).with('init', '--bare')
|
||||
provider.create
|
||||
end
|
||||
end
|
||||
|
||||
context "when the path is a working copy repository" do
|
||||
it "should convert it to a bare repository" do
|
||||
provider.expects(:working_copy_exists?).returns(true)
|
||||
provider.expects(:convert_working_copy_to_bare)
|
||||
provider.create
|
||||
end
|
||||
end
|
||||
|
||||
context "when the path is not a repository" do
|
||||
it "should raise an exception" do
|
||||
expects_directory?(true)
|
||||
proc { provider.create }.should raise_error(Puppet::Error)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context 'destroying' do
|
||||
it "it should remove the directory" do
|
||||
expects_rm_rf
|
||||
provider.destroy
|
||||
end
|
||||
end
|
||||
|
||||
context "checking the revision property" do
|
||||
resource_with :revision do
|
||||
before do
|
||||
expects_chdir
|
||||
provider.expects(:git).with('rev-parse', 'HEAD').returns('currentsha')
|
||||
end
|
||||
|
||||
context "when its SHA is not different than the current SHA" do
|
||||
it "should return the ref" do
|
||||
provider.expects(:git).with('config', 'remote.origin.url').returns('')
|
||||
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('config', 'remote.origin.url').returns('')
|
||||
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
|
||||
|
||||
context "when the source is modified" do
|
||||
resource_with :source => 'git://git@foo.com/bar.git' do
|
||||
it "should update the origin url" do
|
||||
provider.expects(:git).with('config', 'remote.origin.url').returns('old')
|
||||
provider.expects(:git).with('config', 'remote.origin.url', 'git://git@foo.com/bar.git')
|
||||
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
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "setting the revision property" do
|
||||
before do
|
||||
expects_chdir
|
||||
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(: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(: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(: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
|
||||
end
|
||||
|
||||
context "updating references" do
|
||||
it "should use 'git fetch --tags'" do
|
||||
expects_chdir
|
||||
provider.expects(:git).with('config', 'remote.origin.url').returns('')
|
||||
provider.expects(:git).with('fetch', 'origin')
|
||||
provider.expects(:git).with('fetch', '--tags', 'origin')
|
||||
provider.update_references
|
||||
end
|
||||
end
|
||||
|
||||
context "checking if revision" do
|
||||
before do
|
||||
expects_chdir
|
||||
provider.expects(:git).with('branch', '-a').returns(fixture(:git_branch_a))
|
||||
end
|
||||
context "is a local branch" do
|
||||
context "when it's listed in 'git branch -a'", :resource => {:revision => 'feature/foo'} do
|
||||
it "should return true" do
|
||||
provider.should be_local_branch_revision
|
||||
end
|
||||
end
|
||||
context "when it's not listed in 'git branch -a'" , :resource => {:revision => 'feature/notexist'}do
|
||||
it "should return false" do
|
||||
provider.should_not be_local_branch_revision
|
||||
end
|
||||
end
|
||||
end
|
||||
context "is a remote branch" do
|
||||
context "when it's listed in 'git branch -a' with an 'origin/' prefix", :resource => {:revision => 'only/remote'} do
|
||||
it "should return true" do
|
||||
provider.should be_remote_branch_revision
|
||||
end
|
||||
end
|
||||
context "when it's not listed in 'git branch -a' with an 'origin/' prefix" , :resource => {:revision => 'only/local'}do
|
||||
it "should return false" do
|
||||
provider.should_not be_remote_branch_revision
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
require 'spec_helper'
|
||||
|
||||
describe_provider :vcsrepo, :git, :resource => {:path => '/tmp/vcsrepo'} do
|
||||
|
||||
context 'creating' do
|
||||
resource_with :source do
|
||||
resource_with :ensure => :present do
|
||||
context "with a revision that is a remote branch", :resource => {:revision => 'only/remote'} do
|
||||
it "should execute 'git clone' and 'git checkout -b'" do
|
||||
provider.expects(:git).with('clone', resource.value(:source), resource.value(:path))
|
||||
expects_chdir('/')
|
||||
expects_chdir
|
||||
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
|
||||
context "with a revision that is not a remote branch", :resource => {:revision => 'a-commit-or-tag'} do
|
||||
it "should execute 'git clone' and 'git reset --hard'" do
|
||||
provider.expects(:git).with('clone', resource.value(:source), resource.value(:path))
|
||||
expects_chdir('/')
|
||||
expects_chdir
|
||||
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
|
||||
resource_without :revision do
|
||||
it "should execute 'git clone' and submodule commands" do
|
||||
provider.expects(:git).with('clone', resource.value(:source), resource.value(:path))
|
||||
provider.expects(:update_submodules)
|
||||
provider.create
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
resource_with :ensure => :bare do
|
||||
resource_with :revision do
|
||||
it "should just execute 'git clone --bare'" do
|
||||
provider.expects(:git).with('clone', '--bare', resource.value(:source), resource.value(:path))
|
||||
provider.create
|
||||
end
|
||||
end
|
||||
|
||||
resource_without :revision do
|
||||
it "should just execute 'git clone --bare'" do
|
||||
provider.expects(:git).with('clone', '--bare', resource.value(:source), resource.value(:path))
|
||||
provider.create
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "when a source is not given" do
|
||||
resource_with :ensure => :present do
|
||||
context "when the path does not exist" do
|
||||
it "should execute 'git init'" do
|
||||
expects_mkdir
|
||||
expects_chdir
|
||||
expects_directory?(false)
|
||||
provider.expects(:bare_exists?).returns(false)
|
||||
provider.expects(:git).with('init')
|
||||
provider.create
|
||||
end
|
||||
end
|
||||
|
||||
context "when the path is a bare repository" do
|
||||
it "should convert it to a working copy" do
|
||||
provider.expects(:bare_exists?).returns(true)
|
||||
provider.expects(:convert_bare_to_working_copy)
|
||||
provider.create
|
||||
end
|
||||
end
|
||||
|
||||
context "when the path is not a repository" do
|
||||
it "should raise an exception" do
|
||||
provider.expects(:path_exists?).returns(true)
|
||||
proc { provider.create }.should raise_error(Puppet::Error)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
resource_with :ensure => :bare do
|
||||
context "when the path does not exist" do
|
||||
it "should execute 'git init --bare'" do
|
||||
expects_chdir
|
||||
expects_mkdir
|
||||
expects_directory?(false)
|
||||
provider.expects(:working_copy_exists?).returns(false)
|
||||
provider.expects(:git).with('init', '--bare')
|
||||
provider.create
|
||||
end
|
||||
end
|
||||
|
||||
context "when the path is a working copy repository" do
|
||||
it "should convert it to a bare repository" do
|
||||
provider.expects(:working_copy_exists?).returns(true)
|
||||
provider.expects(:convert_working_copy_to_bare)
|
||||
provider.create
|
||||
end
|
||||
end
|
||||
|
||||
context "when the path is not a repository" do
|
||||
it "should raise an exception" do
|
||||
expects_directory?(true)
|
||||
proc { provider.create }.should raise_error(Puppet::Error)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context 'destroying' do
|
||||
it "it should remove the directory" do
|
||||
expects_rm_rf
|
||||
provider.destroy
|
||||
end
|
||||
end
|
||||
|
||||
context "checking the revision property" do
|
||||
resource_with :revision do
|
||||
before do
|
||||
expects_chdir
|
||||
provider.expects(:git).with('rev-parse', 'HEAD').returns('currentsha')
|
||||
end
|
||||
|
||||
context "when its SHA is not different than the current SHA" do
|
||||
it "should return the ref" do
|
||||
provider.expects(:git).with('config', 'remote.origin.url').returns('')
|
||||
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('config', 'remote.origin.url').returns('')
|
||||
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
|
||||
|
||||
context "when the source is modified" do
|
||||
resource_with :source => 'git://git@foo.com/bar.git' do
|
||||
it "should update the origin url" do
|
||||
provider.expects(:git).with('config', 'remote.origin.url').returns('old')
|
||||
provider.expects(:git).with('config', 'remote.origin.url', 'git://git@foo.com/bar.git')
|
||||
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
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "setting the revision property" do
|
||||
before do
|
||||
expects_chdir
|
||||
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(: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(: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(: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
|
||||
end
|
||||
|
||||
context "updating references" do
|
||||
it "should use 'git fetch --tags'" do
|
||||
expects_chdir
|
||||
provider.expects(:git).with('config', 'remote.origin.url').returns('')
|
||||
provider.expects(:git).with('fetch', 'origin')
|
||||
provider.expects(:git).with('fetch', '--tags', 'origin')
|
||||
provider.update_references
|
||||
end
|
||||
end
|
||||
|
||||
context "checking if revision" do
|
||||
before do
|
||||
expects_chdir
|
||||
provider.expects(:git).with('branch', '-a').returns(fixture(:git_branch_a))
|
||||
end
|
||||
context "is a local branch" do
|
||||
context "when it's listed in 'git branch -a'", :resource => {:revision => 'feature/foo'} do
|
||||
it "should return true" do
|
||||
provider.should be_local_branch_revision
|
||||
end
|
||||
end
|
||||
context "when it's not listed in 'git branch -a'" , :resource => {:revision => 'feature/notexist'}do
|
||||
it "should return false" do
|
||||
provider.should_not be_local_branch_revision
|
||||
end
|
||||
end
|
||||
end
|
||||
context "is a remote branch" do
|
||||
context "when it's listed in 'git branch -a' with an 'origin/' prefix", :resource => {:revision => 'only/remote'} do
|
||||
it "should return true" do
|
||||
provider.should be_remote_branch_revision
|
||||
end
|
||||
end
|
||||
context "when it's not listed in 'git branch -a' with an 'origin/' prefix" , :resource => {:revision => 'only/local'}do
|
||||
it "should return false" do
|
||||
provider.should_not be_remote_branch_revision
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,104 +1,104 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe_provider :vcsrepo, :hg, :resource => {:path => '/tmp/vcsrepo'} do
|
||||
|
||||
describe 'creating' do
|
||||
resource_with :source do
|
||||
resource_with :revision do
|
||||
it "should execute 'hg clone -u' with the revision" do
|
||||
provider.expects(:hg).with('clone', '-u',
|
||||
resource.value(:revision),
|
||||
resource.value(:source),
|
||||
resource.value(:path))
|
||||
provider.create
|
||||
end
|
||||
end
|
||||
|
||||
resource_without :revision do
|
||||
it "should just execute 'hg clone' without a revision" do
|
||||
provider.expects(:hg).with('clone', resource.value(:source), resource.value(:path))
|
||||
provider.create
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "when a source is not given" do
|
||||
it "should execute 'hg init'" do
|
||||
provider.expects(:hg).with('init', resource.value(:path))
|
||||
provider.create
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'destroying' do
|
||||
it "it should remove the directory" do
|
||||
expects_rm_rf
|
||||
provider.destroy
|
||||
end
|
||||
end
|
||||
|
||||
describe "checking existence" do
|
||||
it "should check for the directory" do
|
||||
expects_directory?(true, File.join(resource.value(:path), '.hg'))
|
||||
provider.exists?
|
||||
end
|
||||
end
|
||||
|
||||
describe "checking the revision property" do
|
||||
before do
|
||||
expects_chdir
|
||||
end
|
||||
|
||||
context "when given a non-SHA as the resource revision" do
|
||||
before do
|
||||
provider.expects(:hg).with('parents').returns(fixture(:hg_parents))
|
||||
provider.expects(:hg).with('tags').returns(fixture(:hg_tags))
|
||||
end
|
||||
|
||||
context "when its SHA is not different than the current SHA", :resource => {:revision => '0.6'} do
|
||||
it "should return the ref" do
|
||||
provider.revision.should == '0.6'
|
||||
end
|
||||
end
|
||||
|
||||
context "when its SHA is different than the current SHA", :resource => {:revision => '0.5.3'} do
|
||||
it "should return the current SHA" do
|
||||
provider.revision.should == '34e6012c783a'
|
||||
end
|
||||
end
|
||||
end
|
||||
context "when given a SHA as the resource revision" do
|
||||
before do
|
||||
provider.expects(:hg).with('parents').returns(fixture(:hg_parents))
|
||||
end
|
||||
|
||||
context "when it is the same as the current SHA", :resource => {:revision => '34e6012c783a'} do
|
||||
it "should return it" do
|
||||
provider.expects(:hg).with('tags').returns(fixture(:hg_tags))
|
||||
provider.revision.should == resource.value(:revision)
|
||||
end
|
||||
end
|
||||
|
||||
context "when it is not the same as the current SHA", :resource => {:revision => 'not-the-same'} do
|
||||
it "should return the current SHA" do
|
||||
provider.expects(:hg).with('tags').returns(fixture(:hg_tags))
|
||||
provider.revision.should == '34e6012c783a'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "setting the revision property" do
|
||||
before do
|
||||
@revision = '6aa99e9b3ab1'
|
||||
end
|
||||
it "should use 'hg update ---clean -r'" do
|
||||
expects_chdir
|
||||
provider.expects(:hg).with('pull')
|
||||
provider.expects(:hg).with('merge')
|
||||
provider.expects(:hg).with('update', '--clean', '-r', @revision)
|
||||
provider.revision = @revision
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
require 'spec_helper'
|
||||
|
||||
describe_provider :vcsrepo, :hg, :resource => {:path => '/tmp/vcsrepo'} do
|
||||
|
||||
describe 'creating' do
|
||||
resource_with :source do
|
||||
resource_with :revision do
|
||||
it "should execute 'hg clone -u' with the revision" do
|
||||
provider.expects(:hg).with('clone', '-u',
|
||||
resource.value(:revision),
|
||||
resource.value(:source),
|
||||
resource.value(:path))
|
||||
provider.create
|
||||
end
|
||||
end
|
||||
|
||||
resource_without :revision do
|
||||
it "should just execute 'hg clone' without a revision" do
|
||||
provider.expects(:hg).with('clone', resource.value(:source), resource.value(:path))
|
||||
provider.create
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "when a source is not given" do
|
||||
it "should execute 'hg init'" do
|
||||
provider.expects(:hg).with('init', resource.value(:path))
|
||||
provider.create
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'destroying' do
|
||||
it "it should remove the directory" do
|
||||
expects_rm_rf
|
||||
provider.destroy
|
||||
end
|
||||
end
|
||||
|
||||
describe "checking existence" do
|
||||
it "should check for the directory" do
|
||||
expects_directory?(true, File.join(resource.value(:path), '.hg'))
|
||||
provider.exists?
|
||||
end
|
||||
end
|
||||
|
||||
describe "checking the revision property" do
|
||||
before do
|
||||
expects_chdir
|
||||
end
|
||||
|
||||
context "when given a non-SHA as the resource revision" do
|
||||
before do
|
||||
provider.expects(:hg).with('parents').returns(fixture(:hg_parents))
|
||||
provider.expects(:hg).with('tags').returns(fixture(:hg_tags))
|
||||
end
|
||||
|
||||
context "when its SHA is not different than the current SHA", :resource => {:revision => '0.6'} do
|
||||
it "should return the ref" do
|
||||
provider.revision.should == '0.6'
|
||||
end
|
||||
end
|
||||
|
||||
context "when its SHA is different than the current SHA", :resource => {:revision => '0.5.3'} do
|
||||
it "should return the current SHA" do
|
||||
provider.revision.should == '34e6012c783a'
|
||||
end
|
||||
end
|
||||
end
|
||||
context "when given a SHA as the resource revision" do
|
||||
before do
|
||||
provider.expects(:hg).with('parents').returns(fixture(:hg_parents))
|
||||
end
|
||||
|
||||
context "when it is the same as the current SHA", :resource => {:revision => '34e6012c783a'} do
|
||||
it "should return it" do
|
||||
provider.expects(:hg).with('tags').returns(fixture(:hg_tags))
|
||||
provider.revision.should == resource.value(:revision)
|
||||
end
|
||||
end
|
||||
|
||||
context "when it is not the same as the current SHA", :resource => {:revision => 'not-the-same'} do
|
||||
it "should return the current SHA" do
|
||||
provider.expects(:hg).with('tags').returns(fixture(:hg_tags))
|
||||
provider.revision.should == '34e6012c783a'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "setting the revision property" do
|
||||
before do
|
||||
@revision = '6aa99e9b3ab1'
|
||||
end
|
||||
it "should use 'hg update ---clean -r'" do
|
||||
expects_chdir
|
||||
provider.expects(:hg).with('pull')
|
||||
provider.expects(:hg).with('merge')
|
||||
provider.expects(:hg).with('update', '--clean', '-r', @revision)
|
||||
provider.revision = @revision
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,78 +1,78 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe_provider :vcsrepo, :svn, :resource => {:path => '/tmp/vcsrepo'} do
|
||||
|
||||
describe 'creating' do
|
||||
resource_with :source do
|
||||
resource_with :revision do
|
||||
it "should execute 'svn checkout' with a revision" do
|
||||
provider.expects(:svn).with('--non-interactive', 'checkout', '-r',
|
||||
resource.value(:revision),
|
||||
resource.value(:source),
|
||||
resource.value(:path))
|
||||
provider.create
|
||||
end
|
||||
end
|
||||
resource_without :revision do
|
||||
it "should just execute 'svn checkout' without a revision" do
|
||||
provider.expects(:svn).with('--non-interactive', 'checkout',
|
||||
resource.value(:source),
|
||||
resource.value(:path))
|
||||
provider.create
|
||||
end
|
||||
end
|
||||
end
|
||||
resource_without :source do
|
||||
resource_with :fstype do
|
||||
it "should execute 'svnadmin create' with an '--fs-type' option" do
|
||||
provider.expects(:svnadmin).with('create', '--fs-type',
|
||||
resource.value(:fstype),
|
||||
resource.value(:path))
|
||||
provider.create
|
||||
end
|
||||
end
|
||||
resource_without :fstype do
|
||||
it "should execute 'svnadmin create' without an '--fs-type' option" do
|
||||
provider.expects(:svnadmin).with('create', resource.value(:path))
|
||||
provider.create
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'destroying' do
|
||||
it "it should remove the directory" do
|
||||
expects_rm_rf
|
||||
provider.destroy
|
||||
end
|
||||
end
|
||||
|
||||
describe "checking existence" do
|
||||
it "should check for the directory" do
|
||||
expects_directory?(true, File.join(resource.value(:path), '.svn'))
|
||||
provider.exists?
|
||||
end
|
||||
end
|
||||
|
||||
describe "checking the revision property" do
|
||||
before do
|
||||
provider.expects(:svn).with('--non-interactive', 'info').returns(fixture(:svn_info))
|
||||
end
|
||||
it "should use 'svn info'" do
|
||||
expects_chdir
|
||||
provider.revision.should == '3' # From 'Last Changed Rev', not 'Revision'
|
||||
end
|
||||
end
|
||||
|
||||
describe "setting the revision property" do
|
||||
before do
|
||||
@revision = '30'
|
||||
end
|
||||
it "should use 'svn update'" do
|
||||
expects_chdir
|
||||
provider.expects(:svn).with('--non-interactive', 'update', '-r', @revision)
|
||||
provider.revision = @revision
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
require 'spec_helper'
|
||||
|
||||
describe_provider :vcsrepo, :svn, :resource => {:path => '/tmp/vcsrepo'} do
|
||||
|
||||
describe 'creating' do
|
||||
resource_with :source do
|
||||
resource_with :revision do
|
||||
it "should execute 'svn checkout' with a revision" do
|
||||
provider.expects(:svn).with('--non-interactive', 'checkout', '-r',
|
||||
resource.value(:revision),
|
||||
resource.value(:source),
|
||||
resource.value(:path))
|
||||
provider.create
|
||||
end
|
||||
end
|
||||
resource_without :revision do
|
||||
it "should just execute 'svn checkout' without a revision" do
|
||||
provider.expects(:svn).with('--non-interactive', 'checkout',
|
||||
resource.value(:source),
|
||||
resource.value(:path))
|
||||
provider.create
|
||||
end
|
||||
end
|
||||
end
|
||||
resource_without :source do
|
||||
resource_with :fstype do
|
||||
it "should execute 'svnadmin create' with an '--fs-type' option" do
|
||||
provider.expects(:svnadmin).with('create', '--fs-type',
|
||||
resource.value(:fstype),
|
||||
resource.value(:path))
|
||||
provider.create
|
||||
end
|
||||
end
|
||||
resource_without :fstype do
|
||||
it "should execute 'svnadmin create' without an '--fs-type' option" do
|
||||
provider.expects(:svnadmin).with('create', resource.value(:path))
|
||||
provider.create
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'destroying' do
|
||||
it "it should remove the directory" do
|
||||
expects_rm_rf
|
||||
provider.destroy
|
||||
end
|
||||
end
|
||||
|
||||
describe "checking existence" do
|
||||
it "should check for the directory" do
|
||||
expects_directory?(true, File.join(resource.value(:path), '.svn'))
|
||||
provider.exists?
|
||||
end
|
||||
end
|
||||
|
||||
describe "checking the revision property" do
|
||||
before do
|
||||
provider.expects(:svn).with('--non-interactive', 'info').returns(fixture(:svn_info))
|
||||
end
|
||||
it "should use 'svn info'" do
|
||||
expects_chdir
|
||||
provider.revision.should == '3' # From 'Last Changed Rev', not 'Revision'
|
||||
end
|
||||
end
|
||||
|
||||
describe "setting the revision property" do
|
||||
before do
|
||||
@revision = '30'
|
||||
end
|
||||
it "should use 'svn update'" do
|
||||
expects_chdir
|
||||
provider.expects(:svn).with('--non-interactive', 'update', '-r', @revision)
|
||||
provider.revision = @revision
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Resource Type Specs
|
||||
===================
|
||||
|
||||
Define specs for your resource types in this directory.
|
||||
Resource Type Specs
|
||||
===================
|
||||
|
||||
Define specs for your resource types in this directory.
|
||||
|
||||
Reference in New Issue
Block a user