On May 7, 2009, at 12:11 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 <[email protected]>
> ---
> 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 704b48f..335003a 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/arch-release")
>             "Arch"
>         elsif FileTest.exists?("/etc/redhat-release")
> 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


I'm having a hard time believing these tests will work every time.   
What if a higher-priority OS test doesn't use exists?, and uses  
something else to pick the OS version?

I'm willing to accept them for now, but we need to get unique names  
for resolutions so we can actually test them individually. :/

-- 
Work is not always required. There is such a thing as sacred idleness.
     -- George MacDonald
---------------------------------------------------------------------
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 [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
-~----------~----~----~----~------~----~------~--~---

Reply via email to