Dummy provider raises an exception if it is used. Tests to prove it.
authorAaron Stone <aaron@serendipity.cx>
Fri, 19 Oct 2012 08:25:19 +0000 (01:25 -0700)
committerAaron Stone <aaron@serendipity.cx>
Fri, 19 Oct 2012 08:25:19 +0000 (01:25 -0700)
lib/puppet/provider/vcsrepo/dummy.rb
spec/unit/puppet/provider/vcsrepo/dummy_spec.rb [new file with mode: 0644]

index f76e090..f7b4e54 100644 (file)
@@ -4,4 +4,9 @@ Puppet::Type.type(:vcsrepo).provide(:dummy, :parent => Puppet::Provider::Vcsrepo
   desc "Dummy default provider"
 
   defaultfor :vcsrepo => :dummy
+
+  def working_copy_exists?
+    providers = @resource.class.providers.map{|x| x.to_s}.sort.reject{|x| x == "dummy"}.join(", ") rescue "none"
+    raise("vcsrepo resource must have a provider, available: #{providers}")
+  end
 end
diff --git a/spec/unit/puppet/provider/vcsrepo/dummy_spec.rb b/spec/unit/puppet/provider/vcsrepo/dummy_spec.rb
new file mode 100644 (file)
index 0000000..a945888
--- /dev/null
@@ -0,0 +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