Add test for latest?
authorAshley Penney <ashley.penney@puppetlabs.com>
Wed, 18 Sep 2013 22:01:13 +0000 (18:01 -0400)
committerAshley Penney <ashley.penney@puppetlabs.com>
Wed, 18 Sep 2013 22:01:13 +0000 (18:01 -0400)
Also add some fixtures for previous tests.

spec/fixtures/git_branch_feature_bar.txt [new file with mode: 0644]
spec/fixtures/git_branch_none.txt [new file with mode: 0644]
spec/unit/puppet/provider/vcsrepo/git_spec.rb

diff --git a/spec/fixtures/git_branch_feature_bar.txt b/spec/fixtures/git_branch_feature_bar.txt
new file mode 100644 (file)
index 0000000..72d5e20
--- /dev/null
@@ -0,0 +1,14 @@
+  feature/foo
+* feature/bar
+  feature/baz
+  feature/quux
+  only/local
+  master
+  refactor/foo
+  origin/HEAD
+  origin/feature/foo
+  origin/feature/bar
+  origin/feature/baz
+  origin/feature/quux
+  origin/only/remote
+  origin/master
diff --git a/spec/fixtures/git_branch_none.txt b/spec/fixtures/git_branch_none.txt
new file mode 100644 (file)
index 0000000..7207c37
--- /dev/null
@@ -0,0 +1,15 @@
+  feature/foo
+  feature/bar
+  feature/baz
+  feature/quux
+  only/local
+  master
+* (no branch)  
+  refactor/foo
+  origin/HEAD
+  origin/feature/foo
+  origin/feature/bar
+  origin/feature/baz
+  origin/feature/quux
+  origin/only/remote
+  origin/master
index d2769ae..cc369d9 100644 (file)
@@ -296,4 +296,25 @@ describe Puppet::Type.type(:vcsrepo).provider(:git_provider) do
     end
   end
 
+  describe 'latest?' do
+    before do
+      expects_chdir('/tmp/test')
+    end
+    context 'when true' do
+      it do
+        provider.expects(:revision).returns('testrev')
+        provider.expects(:latest).returns('testrev')
+        provider.latest?.should be_true
+      end
+    end
+    context 'when false' do
+      it do
+        provider.expects(:revision).returns('master')
+        provider.expects(:latest).returns('testrev')
+        provider.latest?.should be_false
+      end
+    end
+  end
+
+
 end