Merge pull request #273 from hunner/fix_trustcert
[puppet_vcsrepo.git] / spec / unit / puppet / provider / vcsrepo / svn_spec.rb
index 494da52..6a37c20 100644 (file)
@@ -52,6 +52,36 @@ describe Puppet::Type.type(:vcsrepo).provider(:svn) do
         provider.create
       end
     end
+    
+    context "with depth" do
+      it "should execute 'svn checkout' with a depth" do
+        resource[:source] = 'exists'
+        resource[:depth] = 'infinity'
+        provider.expects(:svn).with('--non-interactive', 'checkout', '--depth', 'infinity',
+          resource.value(:source),
+          resource.value(:path))
+        provider.create
+      end
+    end
+    
+    context "with trust_server_cert" do
+      it "should execute 'svn checkout' without a trust-server-cert" do
+        resource[:source] = 'exists'
+        resource[:trust_server_cert] = :false
+        provider.expects(:svn).with('--non-interactive', 'checkout',
+          resource.value(:source),
+          resource.value(:path))
+        provider.create
+      end
+      it "should execute 'svn checkout' with a trust-server-cert" do
+        resource[:source] = 'exists'
+        resource[:trust_server_cert] = :true
+        provider.expects(:svn).with('--non-interactive', '--trust-server-cert', 'checkout',
+          resource.value(:source),
+          resource.value(:path))
+        provider.create
+      end
+    end
   end
 
   describe 'destroying' do
@@ -83,10 +113,22 @@ describe Puppet::Type.type(:vcsrepo).provider(:svn) 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
+    context 'with conflict' do
+      it "should use 'svn update'" do
+        resource[:conflict] = 'theirs-full'
+        expects_chdir
+        provider.expects(:svn).with('--non-interactive', 'update',
+                                    '-r', @revision,
+                                    '--accept', resource.value(:conflict))
+        provider.revision = @revision
+      end
+    end
+    context 'without conflict' do
+      it "should use 'svn update'" do
+        expects_chdir
+        provider.expects(:svn).with('--non-interactive', 'update', '-r', @revision)
+        provider.revision = @revision
+      end
     end
   end
 
@@ -94,11 +136,24 @@ describe Puppet::Type.type(:vcsrepo).provider(:svn) do
     before do
       @revision = '30'
     end
-    it "should use 'svn switch'" do
-      resource[:source] = 'an-unimportant-value'
-      expects_chdir
-      provider.expects(:svn).with('--non-interactive', 'switch', '-r', @revision, 'an-unimportant-value')
-      provider.revision = @revision
+    context 'with conflict' do
+      it "should use 'svn switch'" do
+        resource[:source] = 'an-unimportant-value'
+        resource[:conflict] = 'theirs-full'
+        expects_chdir
+        provider.expects(:svn).with('--non-interactive', 'switch',
+                                    '-r', @revision, 'an-unimportant-value',
+                                    '--accept', resource.value(:conflict))
+        provider.revision = @revision
+      end
+    end
+    context 'without conflict' do
+      it "should use 'svn switch'" do
+        resource[:source] = 'an-unimportant-value'
+        expects_chdir
+        provider.expects(:svn).with('--non-interactive', 'switch', '-r', @revision, 'an-unimportant-value')
+        provider.revision = @revision
+      end
     end
   end