On 18 August 2010 23:58, Rein Henrichs <[email protected]> wrote: > When Facter returns operatingsystem as "oel" or "ovs", the > operatingsystemrelease fact does not catch these properly, causing an > error. > > Specs added to catch failure and case statement updated to catch "oel" > and "ovs" as well as "OEL" and "OVS"
+1 > > Signed-off-by: Rein Henrichs <[email protected]> > --- > lib/facter/operatingsystemrelease.rb | 4 +- > spec/unit/operatingsystemrelease.rb | 39 > ++++++++++++++++++++++++++++++++++ > 2 files changed, 41 insertions(+), 2 deletions(-) > create mode 100644 spec/unit/operatingsystemrelease.rb > > diff --git a/lib/facter/operatingsystemrelease.rb > b/lib/facter/operatingsystemrelease.rb > index 30f2989..280208b 100644 > --- a/lib/facter/operatingsystemrelease.rb > +++ b/lib/facter/operatingsystemrelease.rb > @@ -8,9 +8,9 @@ Facter.add(:operatingsystemrelease) do > releasefile = "/etc/fedora-release" > when "MeeGo" > releasefile = "/etc/meego-release" > - when "OEL" > + when "OEL", "oel" > releasefile = "/etc/enterprise-release" > - when "OVS" > + when "OVS", "ovs" > releasefile = "/etc/ovs-release" > end > File::open(releasefile, "r") do |f| > diff --git a/spec/unit/operatingsystemrelease.rb > b/spec/unit/operatingsystemrelease.rb > new file mode 100644 > index 0000000..31d4ae8 > --- /dev/null > +++ b/spec/unit/operatingsystemrelease.rb > @@ -0,0 +1,39 @@ > +#!/usr/bin/env ruby > + > +require File.dirname(__FILE__) + '/../spec_helper' > + > +require 'facter' > + > +describe "Operating System Release fact" do > + > + before do > + Facter.clear > + end > + > + after do > + Facter.clear > + end > + > + test_cases = { > + "CentOS" => "/etc/redhat-release", > + "RedHat" => "/etc/redhat-release", > + "Fedora" => "/etc/fedora-release", > + "MeeGo" => "/etc/meego-release", > + "OEL" => "/etc/enterprise-release", > + "oel" => "/etc/enterprise-release", > + "OVS" => "/etc/ovs-release", > + "ovs" => "/etc/ovs-release" > + } > + > + test_cases.each do |system, file| > + context "with operatingsystem reported as #{system.inspect}" do > + it "should read the #{file.inspect} file" do > + Facter.fact(:operatingsystem).stubs(:value).returns(system) > + > + File.expects(:open).with(file, "r").at_least(1) > + > + Facter.fact(:operatingsystemrelease).value > + end > + end > + end > +end > -- > 1.7.0.4 > > -- > You received this message because you are subscribed to the Google Groups > "Puppet Developers" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/puppet-dev?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Puppet Developers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
