Signed-off-by: Michael Kincaid <[email protected]>
---
Local-branch: ticket/next/4980
lib/facter/architecture.rb | 10 +------
spec/unit/architecture_spec.rb | 54 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 55 insertions(+), 9 deletions(-)
create mode 100755 spec/unit/architecture_spec.rb
diff --git a/lib/facter/architecture.rb b/lib/facter/architecture.rb
index cd606a2..5be1bcb 100644
--- a/lib/facter/architecture.rb
+++ b/lib/facter/architecture.rb
@@ -12,14 +12,13 @@
#
Facter.add(:architecture) do
- confine :kernel => [:linux, :"gnu/kfreebsd"]
setcode do
model = Facter.value(:hardwaremodel)
case model
# most linuxen use "x86_64"
when "x86_64"
case Facter.value(:operatingsystem)
- when "Debian", "Gentoo", "GNU/kFreeBSD"
+ when "Debian", "Gentoo", "GNU/kFreeBSD", "Ubuntu"
"amd64"
else
model
@@ -37,10 +36,3 @@ Facter.add(:architecture) do
end
end
-Facter.add(:architecture) do
- confine :kernel => :openbsd
- setcode do
- architecture = Facter.value(:hardwaremodel)
- end
-end
-
diff --git a/spec/unit/architecture_spec.rb b/spec/unit/architecture_spec.rb
new file mode 100755
index 0000000..253de57
--- /dev/null
+++ b/spec/unit/architecture_spec.rb
@@ -0,0 +1,54 @@
+#!/usr/bin/env ruby
+
+require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+
+require 'facter'
+
+describe "Architecture fact" do
+
+ it "should default to the hardware model" do
+ Facter.fact(:hardwaremodel).stubs(:value).returns("NonSpecialCasedHW")
+
+ Facter.fact(:architecture).value.should == "NonSpecialCasedHW"
+ end
+
+ os_archs = Hash.new
+ os_archs = {
+ ["Debian","x86_64"] => "amd64",
+ ["Gentoo","x86_64"] => "amd64",
+ ["GNU/kFreeBSD","x86_64"] => "amd64",
+ ["Ubuntu","x86_64"] => "amd64",
+ ["Gentoo","i386"] => "x86",
+ ["Gentoo","i486"] => "x86",
+ ["Gentoo","i586"] => "x86",
+ ["Gentoo","i686"] => "x86",
+ ["Gentoo","pentium"] => "x86",
+ }
+ generic_archs = Hash.new
+ generic_archs = {
+ "i386" => "i386",
+ "i486" => "i386",
+ "i586" => "i386",
+ "i686" => "i386",
+ "pentium" => "i386",
+ }
+
+ os_archs.each do |pair, result|
+ it "should be #{result} if os is #{pair[0]} and hardwaremodel is
#{pair[1]}" do
+ Facter.fact(:operatingsystem).stubs(:value).returns(pair[0])
+ Facter.fact(:hardwaremodel).stubs(:value).returns(pair[1])
+
+ Facter.fact(:architecture).value.should == result
+ end
+ end
+
+ generic_archs.each do |hw, result|
+ it "should be #{result} if hardwaremodel is #{hw}" do
+ Facter.fact(:hardwaremodel).stubs(:value).returns(hw)
+
Facter.fact(:operatingsystem).stubs(:value).returns("NonSpecialCasedOS")
+
+ Facter.fact(:architecture).value.should == result
+ end
+ end
+
+end
--
1.7.4.1
--
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.