diff options
author | Bruce Williams <bruce@codefluency.com> | 2010-03-13 17:32:17 -0800 |
---|---|---|
committer | Bruce Williams <bruce@codefluency.com> | 2010-03-13 17:32:17 -0800 |
commit | c714947908b69c538ea9d050d4375e2b3f19e7ac (patch) | |
tree | 1a464a8d7534e43e30d09dd914cbf231f1a29601 /spec | |
parent | 6adc8745c6565391f5da534306c3ec206da9dc21 (diff) | |
download | puppet-vcsrepo-c714947908b69c538ea9d050d4375e2b3f19e7ac.tar.gz puppet-vcsrepo-c714947908b69c538ea9d050d4375e2b3f19e7ac.tar.bz2 |
Support Mercurial tags, restructure examples
Diffstat (limited to 'spec')
-rw-r--r-- | spec/fixtures/hg_tags.txt | 18 | ||||
-rw-r--r-- | spec/unit/puppet/provider/vcsrepo/hg_spec.rb | 52 |
2 files changed, 65 insertions, 5 deletions
diff --git a/spec/fixtures/hg_tags.txt b/spec/fixtures/hg_tags.txt new file mode 100644 index 0000000..53792e5 --- /dev/null +++ b/spec/fixtures/hg_tags.txt @@ -0,0 +1,18 @@ +tip 1019:bca3f20b249b +0.9.1 1017:76ce7cca95d8 +0.9 1001:dbaa6f4ec585 +0.8 839:65b66ac0fc83 +0.7.1 702:e1357f00129f +0.7 561:7b2af3b4c968 +0.6.3 486:e38077f4e4aa +0.6.2 405:07bb099b7b10 +0.6.1 389:93750f3fbbe2 +0.6 369:34e6012c783a +0.5.3 321:5ffa6ae7e699 +0.5.2 318:fdc2c2e4cebe +0.5.1 315:33a5ea0cbe7a +0.5 313:47490716f4c9 +0.4 240:47fa3a14cc63 +0.3.1 132:bc231db18e1c +0.3 130:661615e510dd +0.2 81:f98d13b442f6 diff --git a/spec/unit/puppet/provider/vcsrepo/hg_spec.rb b/spec/unit/puppet/provider/vcsrepo/hg_spec.rb index 56189a3..0df796e 100644 --- a/spec/unit/puppet/provider/vcsrepo/hg_spec.rb +++ b/spec/unit/puppet/provider/vcsrepo/hg_spec.rb @@ -70,12 +70,54 @@ describe provider_class do describe "when checking the revision property" do before do - @resource.expects(:value).with(:path).returns(@path) - end - it "should use 'hg tip'" do - @provider.expects('hg').with('parents').returns(fixture(:hg_parents)) + @resource.expects(:value).with(:path).returns(@path).at_least_once Dir.expects(:chdir).with(@path).yields - @provider.revision.should == '34e6012c783a' + end + context "when given a non-SHA as the resource revision" do + before do + @provider.expects(:hg).with('parents').returns(fixture(:hg_parents)) + end + context "when its SHA is not different than the current SHA" do + before do + @resource.expects(:value).with(:revision).returns('0.6').at_least_once + end + it "should return the ref" do + @provider.expects(:hg).with('tags').returns(fixture(:hg_tags)) + @provider.revision.should == '0.6' + end + end + context "when its SHA is different than the current SHA" do + before do + @resource.expects(:value).with(:revision).returns('0.5.3').at_least_once + end + it "should return the current SHA" do + @provider.expects(:hg).with('tags').returns(fixture(:hg_tags)) + @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" do + before do + @resource.expects(:value).with(:revision).returns('34e6012c783a').at_least_once + end + it "should return it" do + @provider.expects(:hg).with('tags').never + @provider.revision.should == '34e6012c783a' + end + end + context "when it is not the same as the current SHA" do + before do + @resource.expects(:value).with(:revision).returns('34e6012c7').at_least_once + end + it "should return the current SHA" do + @provider.expects(:hg).with('tags').returns(fixture(:hg_tags)) + @provider.revision.should == '34e6012c783a' + end + end end end |