+1 On May 6, 2009, at 12:17 AM, Paul Nasrat wrote:
> > Added tests for operatingsystem fact covering the two simple cases > and a test > for this specific interaction of release files > > We should take some time to add tests when we're adding or changing > new > operatingsystem facts > > Signed-off-by: Paul Nasrat <pnas...@googlemail.com> > --- > lib/facter/operatingsystem.rb | 8 +++++--- > spec/unit/operatingsystem.rb | 36 ++++++++++++++++++++++++++++++++ > ++++ > 2 files changed, 41 insertions(+), 3 deletions(-) > create mode 100644 spec/unit/operatingsystem.rb > > diff --git a/lib/facter/operatingsystem.rb b/lib/facter/ > operatingsystem.rb > index 52f889b..d3b1123 100644 > --- a/lib/facter/operatingsystem.rb > +++ b/lib/facter/operatingsystem.rb > @@ -23,9 +23,11 @@ Facter.add(:operatingsystem) do > elsif FileTest.exists?("/etc/arch-release") > "Archlinux" > elsif FileTest.exists?("/etc/enterprise-release") > - "OEL" > - elsif FileTest.exists?("/etc/ovs-release") > - "OVS" > + if FileTest.exists?("/etc/ovs-release") > + "OVS" > + else > + "OEL" > + end > elsif FileTest.exists?("/etc/redhat-release") > txt = File.read("/etc/redhat-release") > if txt =~ /centos/i > diff --git a/spec/unit/operatingsystem.rb b/spec/unit/ > operatingsystem.rb > new file mode 100644 > index 0000000..4c3fb3b > --- /dev/null > +++ b/spec/unit/operatingsystem.rb > @@ -0,0 +1,36 @@ > +#!/usr/bin/env ruby > + > +require File.dirname(__FILE__) + '/../spec_helper' > + > +require 'facter' > + > +describe "Operating System fact" do > + > + > + after do > + Facter.clear > + end > + > + it "should default to the kernel name" do > + Facter.fact(:kernel).stubs(:value).returns("Nutmeg") > + > + Facter.fact(:operatingsystem).value.should == "Nutmeg" > + end > + > + it "should be Solaris for SunOS" do > + Facter.fact(:kernel).stubs(:value).returns("SunOS") > + > + Facter.fact(:operatingsystem).value.should == "Solaris" > + end > + > + it "should identify Oracle VM as OVS" do > + > + Facter.fact(:kernel).stubs(:value).returns("Linux") > + FileTest.stubs(:exists?).returns false > + > + FileTest.expects(:exists?).with("/etc/ovs-release").returns > true > + FileTest.expects(:exists?).with("/etc/enterprise- > release").returns true > + > + Facter.fact(:operatingsystem).value.should == "OVS" > + end > +end > -- > 1.6.1.3 > > > > -- Every generation laughs at the old fashions, but follows religiously the new. -- Henry David Thoreau --------------------------------------------------------------------- Luke Kanies | http://reductivelabs.com | http://madstop.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Puppet Developers" group. To post to this group, send email to puppet-dev@googlegroups.com To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en -~----------~----~----~----~------~----~------~--~---