facter 2.1.0-x64-mingw32 → 2.2.0-x64-mingw32

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of facter might be problematic. Click here for more details.

Files changed (139) hide show
  1. data/COMMITTERS.md +25 -34
  2. data/CONTRIBUTING.md +27 -5
  3. data/README.md +32 -0
  4. data/ext/build_defaults.yaml +1 -1
  5. data/ext/debian/control +3 -2
  6. data/ext/osx/file_mapping.yaml +5 -0
  7. data/ext/redhat/facter.spec.erb +4 -1
  8. data/lib/facter/Cfkey.rb +2 -2
  9. data/lib/facter/architecture.rb +2 -2
  10. data/lib/facter/augeasversion.rb +2 -2
  11. data/lib/facter/blockdevices.rb +12 -12
  12. data/lib/facter/dhcp_servers.rb +4 -4
  13. data/lib/facter/domain.rb +4 -4
  14. data/lib/facter/ec2.rb +17 -0
  15. data/lib/facter/ec2/rest.rb +2 -2
  16. data/lib/facter/facterversion.rb +2 -2
  17. data/lib/facter/filesystems.rb +10 -3
  18. data/lib/facter/fqdn.rb +1 -1
  19. data/lib/facter/gid.rb +16 -0
  20. data/lib/facter/hardwareisa.rb +3 -3
  21. data/lib/facter/hardwaremodel.rb +3 -3
  22. data/lib/facter/hostname.rb +1 -1
  23. data/lib/facter/id.rb +4 -4
  24. data/lib/facter/interfaces.rb +3 -0
  25. data/lib/facter/ipaddress6.rb +9 -9
  26. data/lib/facter/kernel.rb +2 -2
  27. data/lib/facter/kernelmajversion.rb +2 -2
  28. data/lib/facter/kernelrelease.rb +4 -4
  29. data/lib/facter/kernelversion.rb +3 -3
  30. data/lib/facter/ldom.rb +11 -0
  31. data/lib/facter/lsbdistcodename.rb +8 -4
  32. data/lib/facter/lsbdistdescription.rb +6 -10
  33. data/lib/facter/lsbdistid.rb +8 -4
  34. data/lib/facter/lsbdistrelease.rb +8 -4
  35. data/lib/facter/lsbmajdistrelease.rb +7 -12
  36. data/lib/facter/lsbminordistrelease.rb +22 -0
  37. data/lib/facter/lsbrelease.rb +8 -4
  38. data/lib/facter/macaddress.rb +1 -0
  39. data/lib/facter/macosx.rb +1 -1
  40. data/lib/facter/manufacturer.rb +3 -3
  41. data/lib/facter/memory.rb +8 -8
  42. data/lib/facter/netmask.rb +2 -1
  43. data/lib/facter/network.rb +3 -3
  44. data/lib/facter/operatingsystem.rb +9 -126
  45. data/lib/facter/operatingsystem/base.rb +61 -0
  46. data/lib/facter/operatingsystem/cumuluslinux.rb +27 -0
  47. data/lib/facter/operatingsystem/implementation.rb +30 -0
  48. data/lib/facter/operatingsystem/linux.rb +467 -0
  49. data/lib/facter/operatingsystem/sunos.rb +54 -0
  50. data/lib/facter/operatingsystem/vmkernel.rb +11 -0
  51. data/lib/facter/operatingsystem/windows.rb +37 -0
  52. data/lib/facter/operatingsystemmajrelease.rb +14 -33
  53. data/lib/facter/operatingsystemrelease.rb +14 -235
  54. data/lib/facter/os.rb +69 -0
  55. data/lib/facter/osfamily.rb +4 -23
  56. data/lib/facter/partitions.rb +4 -3
  57. data/lib/facter/path.rb +2 -2
  58. data/lib/facter/physicalprocessorcount.rb +10 -74
  59. data/lib/facter/processor.rb +13 -129
  60. data/lib/facter/processors.rb +60 -0
  61. data/lib/facter/processors/os.rb +234 -0
  62. data/lib/facter/ps.rb +5 -4
  63. data/lib/facter/puppetversion.rb +1 -1
  64. data/lib/facter/rackspace.rb +34 -0
  65. data/lib/facter/rubysitedir.rb +3 -0
  66. data/lib/facter/rubyversion.rb +2 -2
  67. data/lib/facter/selinux.rb +57 -2
  68. data/lib/facter/ssh.rb +1 -0
  69. data/lib/facter/system_uptime.rb +42 -0
  70. data/lib/facter/timezone.rb +1 -1
  71. data/lib/facter/uptime.rb +5 -23
  72. data/lib/facter/uptime_days.rb +4 -6
  73. data/lib/facter/uptime_hours.rb +4 -6
  74. data/lib/facter/uptime_seconds.rb +5 -9
  75. data/lib/facter/util/formatter.rb +1 -1
  76. data/lib/facter/util/manufacturer.rb +1 -1
  77. data/lib/facter/util/partitions.rb +3 -1
  78. data/lib/facter/util/partitions/linux.rb +1 -1
  79. data/lib/facter/util/partitions/openbsd.rb +35 -0
  80. data/lib/facter/util/uptime.rb +4 -3
  81. data/lib/facter/util/virtual.rb +3 -1
  82. data/lib/facter/util/xendomains.rb +12 -3
  83. data/lib/facter/version.rb +1 -1
  84. data/lib/facter/virtual.rb +24 -23
  85. data/lib/facter/vlans.rb +1 -1
  86. data/lib/facter/xendomains.rb +1 -1
  87. data/lib/facter/zfs_version.rb +6 -2
  88. data/lib/facter/zones.rb +6 -5
  89. data/lib/facter/zpool_version.rb +1 -1
  90. data/spec/fixtures/cpuinfo/amd64dual-grep +2 -0
  91. data/spec/fixtures/cpuinfo/amd64twentyfour-grep +24 -0
  92. data/spec/fixtures/cpuinfo/two_multicore-grep +4 -0
  93. data/spec/fixtures/cpuinfo/two_singlecore-grep +2 -0
  94. data/spec/fixtures/unit/processors/os/darwin-system-profiler +287 -0
  95. data/spec/fixtures/unit/zfs_version/zfs_new +61 -0
  96. data/spec/fixtures/unit/zfs_version/zfs_old +43 -0
  97. data/spec/fixtures/unit/zfs_version/zfsonlinux_0.6.1 +13 -0
  98. data/spec/fixtures/unit/zpool_version/zfsonlinux_0.6.1 +48 -0
  99. data/spec/unit/ec2/rest_spec.rb +6 -6
  100. data/spec/unit/gid_spec.rb +22 -0
  101. data/spec/unit/hardwaremodel_spec.rb +2 -0
  102. data/spec/unit/lsbdistcodename_spec.rb +22 -17
  103. data/spec/unit/lsbdistdescription_spec.rb +22 -17
  104. data/spec/unit/lsbdistid_spec.rb +23 -18
  105. data/spec/unit/lsbdistrelease_spec.rb +22 -17
  106. data/spec/unit/lsbmajdistrelease_spec.rb +23 -6
  107. data/spec/unit/lsbminordistrelease_spec.rb +31 -0
  108. data/spec/unit/lsbrelease_spec.rb +22 -17
  109. data/spec/unit/macaddress_spec.rb +3 -0
  110. data/spec/unit/operatingsystem/base_spec.rb +76 -0
  111. data/spec/unit/operatingsystem/cumuluslinux_spec.rb +40 -0
  112. data/spec/unit/operatingsystem/implementation_spec.rb +49 -0
  113. data/spec/unit/operatingsystem/linux_spec.rb +538 -0
  114. data/spec/unit/operatingsystem/sunos_spec.rb +144 -0
  115. data/spec/unit/operatingsystem/vmkernel_spec.rb +13 -0
  116. data/spec/unit/operatingsystem/windows_spec.rb +68 -0
  117. data/spec/unit/operatingsystem_spec.rb +10 -153
  118. data/spec/unit/operatingsystemmajrelease_spec.rb +14 -31
  119. data/spec/unit/operatingsystemrelease_spec.rb +13 -229
  120. data/spec/unit/os_spec.rb +131 -0
  121. data/spec/unit/osfamily_spec.rb +9 -54
  122. data/spec/unit/partitions_spec.rb +41 -3
  123. data/spec/unit/physicalprocessorcount_spec.rb +6 -78
  124. data/spec/unit/processor_spec.rb +18 -381
  125. data/spec/unit/processors/os_spec.rb +446 -0
  126. data/spec/unit/processors_spec.rb +203 -0
  127. data/spec/unit/rackspace_spec.rb +40 -0
  128. data/spec/unit/system_uptime_spec.rb +80 -0
  129. data/spec/unit/util/formatter_spec.rb +5 -0
  130. data/spec/unit/util/macaddress_spec.rb +2 -0
  131. data/spec/unit/util/processor_spec.rb +120 -0
  132. data/spec/unit/util/uptime_spec.rb +3 -4
  133. data/spec/unit/util/virtual_spec.rb +8 -0
  134. data/spec/unit/util/xendomains_spec.rb +54 -9
  135. data/spec/unit/virtual_spec.rb +8 -1
  136. data/spec/unit/zfs_version_spec.rb +20 -8
  137. data/spec/unit/zpool_version_spec.rb +5 -0
  138. metadata +658 -589
  139. checksums.yaml +0 -7
@@ -1,236 +1,20 @@
1
1
  #! /usr/bin/env ruby
2
2
 
3
- require 'facter/util/file_read'
4
3
  require 'spec_helper'
5
4
 
6
5
  describe "Operating System Release fact" do
7
-
8
- before do
9
- Facter.clear
10
- end
11
-
12
- after do
13
- Facter.clear
14
- end
15
-
16
- test_cases = {
17
- "OpenWrt" => "/etc/openwrt_version",
18
- "CentOS" => "/etc/redhat-release",
19
- "RedHat" => "/etc/redhat-release",
20
- "LinuxMint" => "/etc/linuxmint/info",
21
- "Scientific" => "/etc/redhat-release",
22
- "Fedora" => "/etc/fedora-release",
23
- "MeeGo" => "/etc/meego-release",
24
- "OEL" => "/etc/enterprise-release",
25
- "oel" => "/etc/enterprise-release",
26
- "OVS" => "/etc/ovs-release",
27
- "ovs" => "/etc/ovs-release",
28
- "OracleLinux" => "/etc/oracle-release",
29
- "Ascendos" => "/etc/redhat-release",
30
- }
31
-
32
- test_cases.each do |system, file|
33
- describe "with operatingsystem reported as #{system.inspect}" do
34
- it "should read the #{file.inspect} file" do
35
- Facter.fact(:operatingsystem).stubs(:value).returns(system)
36
-
37
- Facter::Util::FileRead.expects(:read).with(file).at_least(1)
38
-
39
- Facter.fact(:operatingsystemrelease).value
40
- end
41
- end
42
- end
43
-
44
- it "does not include trailing whitespace on Debian" do
45
- Facter.fact(:operatingsystem).stubs(:value).returns("Debian")
46
- Facter::Util::FileRead.stubs(:read).returns("6.0.6\n")
47
- Facter.fact(:operatingsystemrelease).value.should == "6.0.6"
48
- end
49
-
50
- it "for VMWareESX it should run the vmware -v command" do
51
- Facter.fact(:kernel).stubs(:value).returns("VMkernel")
52
- Facter.fact(:kernelrelease).stubs(:value).returns("4.1.0")
53
- Facter.fact(:operatingsystem).stubs(:value).returns("VMwareESX")
54
-
55
- Facter::Core::Execution.stubs(:exec).with('vmware -v').returns('foo')
56
-
57
- Facter.fact(:operatingsystemrelease).value
58
- end
59
-
60
- it "for Alpine it should use the contents of /etc/alpine-release" do
61
- Facter.fact(:kernel).stubs(:value).returns("Linux")
62
- Facter.fact(:operatingsystem).stubs(:value).returns("Alpine")
63
-
64
- File.expects(:read).with("/etc/alpine-release").returns("foo")
65
-
66
- Facter.fact(:operatingsystemrelease).value.should == "foo"
67
- end
68
-
69
- describe "with operatingsystem reported as Solaris" do
70
-
71
- before :each do
72
- Facter.fact(:kernel).stubs(:value).returns('SunOS')
73
- Facter.fact(:osfamily).stubs(:value).returns('Solaris')
74
- end
75
-
76
- {
77
- 'Solaris 8 s28_38shwp2 SPARC' => '28',
78
- 'Solaris 8 6/00 s28s_u1wos_08 SPARC' => '28_u1',
79
- 'Solaris 8 10/00 s28s_u2wos_11b SPARC' => '28_u2',
80
- 'Solaris 8 1/01 s28s_u3wos_08 SPARC' => '28_u3',
81
- 'Solaris 8 4/01 s28s_u4wos_08 SPARC' => '28_u4',
82
- 'Solaris 8 7/01 s28s_u5wos_08 SPARC' => '28_u5',
83
- 'Solaris 8 10/01 s28s_u6wos_08a SPARC' => '28_u6',
84
- 'Solaris 8 2/02 s28s_u7wos_08a SPARC' => '28_u7',
85
- 'Solaris 8 HW 12/02 s28s_hw1wos_06a SPARC' => '28',
86
- 'Solaris 8 HW 5/03 s28s_hw2wos_06a SPARC' => '28',
87
- 'Solaris 8 HW 7/03 s28s_hw3wos_05a SPARC' => '28',
88
- 'Solaris 8 2/04 s28s_hw4wos_05a SPARC' => '28',
89
- 'Solaris 9 s9_58shwpl3 SPARC' => '9',
90
- 'Solaris 9 9/02 s9s_u1wos_08b SPARC' => '9_u1',
91
- 'Solaris 9 12/02 s9s_u2wos_10 SPARC' => '9_u2',
92
- 'Solaris 9 4/03 s9s_u3wos_08 SPARC' => '9_u3',
93
- 'Solaris 9 8/03 s9s_u4wos_08a SPARC' => '9_u4',
94
- 'Solaris 9 12/03 s9s_u5wos_08b SPARC' => '9_u5',
95
- 'Solaris 9 4/04 s9s_u6wos_08a SPARC' => '9_u6',
96
- 'Solaris 9 9/04 s9s_u7wos_09 SPARC' => '9_u7',
97
- 'Solaris 9 9/05 s9s_u8wos_05 SPARC' => '9_u8',
98
- 'Solaris 9 9/05 HW s9s_u9wos_06b SPARC' => '9_u9',
99
- 'Solaris 10 3/05 s10_74L2a SPARC' => '10',
100
- 'Solaris 10 3/05 HW1 s10s_wos_74L2a SPARC' => '10',
101
- 'Solaris 10 3/05 HW2 s10s_hw2wos_05 SPARC' => '10',
102
- 'Solaris 10 1/06 s10s_u1wos_19a SPARC' => '10_u1',
103
- 'Solaris 10 6/06 s10s_u2wos_09a SPARC' => '10_u2',
104
- 'Solaris 10 11/06 s10s_u3wos_10 SPARC' => '10_u3',
105
- 'Solaris 10 8/07 s10s_u4wos_12b SPARC' => '10_u4',
106
- 'Solaris 10 5/08 s10s_u5wos_10 SPARC' => '10_u5',
107
- 'Solaris 10 10/08 s10s_u6wos_07b SPARC' => '10_u6',
108
- 'Solaris 10 5/09 s10s_u7wos_08 SPARC' => '10_u7',
109
- 'Solaris 10 10/09 s10s_u8wos_08a SPARC' => '10_u8',
110
- 'Oracle Solaris 10 9/10 s10s_u9wos_14a SPARC' => '10_u9',
111
- 'Oracle Solaris 10 8/11 s10s_u10wos_17b SPARC' => '10_u10',
112
- 'Solaris 10 3/05 HW1 s10x_wos_74L2a X86' => '10',
113
- 'Solaris 10 1/06 s10x_u1wos_19a X86' => '10_u1',
114
- 'Solaris 10 6/06 s10x_u2wos_09a X86' => '10_u2',
115
- 'Solaris 10 11/06 s10x_u3wos_10 X86' => '10_u3',
116
- 'Solaris 10 8/07 s10x_u4wos_12b X86' => '10_u4',
117
- 'Solaris 10 5/08 s10x_u5wos_10 X86' => '10_u5',
118
- 'Solaris 10 10/08 s10x_u6wos_07b X86' => '10_u6',
119
- 'Solaris 10 5/09 s10x_u7wos_08 X86' => '10_u7',
120
- 'Solaris 10 10/09 s10x_u8wos_08a X86' => '10_u8',
121
- 'Oracle Solaris 10 9/10 s10x_u9wos_14a X86' => '10_u9',
122
- 'Oracle Solaris 10 8/11 s10x_u10wos_17b X86' => '10_u10',
123
- 'Oracle Solaris 11 11/11 X86' => '11 11/11',
124
- 'Oracle Solaris 11.1 SPARC' => '11.1'
125
- }.each do |fakeinput,expected_output|
126
- it "should be able to parse a release of #{fakeinput}" do
127
- Facter::Util::FileRead.stubs(:read).with('/etc/release').returns fakeinput
128
- Facter.fact(:operatingsystemrelease).value.should == expected_output
129
- end
130
- end
131
-
132
- context "malformed /etc/release files" do
133
- it "should fallback to the kernelrelease fact if /etc/release is empty" do
134
- Facter::Util::FileRead.stubs(:read).with('/etc/release').
135
- raises EOFError
136
- Facter.expects(:warn).with(regexp_matches(/Could not retrieve fact='operatingsystemrelease'.*EOFError/))
137
- Facter.fact(:operatingsystemrelease).value.
138
- should == Facter.fact(:kernelrelease).value
139
- end
140
-
141
- it "should fallback to the kernelrelease fact if /etc/release is not present" do
142
- Facter::Util::FileRead.stubs(:read).with('/etc/release').
143
- raises Errno::ENOENT
144
- Facter.expects(:warn).with(regexp_matches(/Could not retrieve fact='operatingsystemrelease'.*No such file or directory/))
145
- Facter.fact(:operatingsystemrelease).value.
146
- should == Facter.fact(:kernelrelease).value
147
- end
148
-
149
- it "should fallback to the kernelrelease fact if /etc/release cannot be parsed" do
150
- Facter::Util::FileRead.stubs(:read).with('/etc/release').
151
- returns 'some future release string'
152
- Facter.fact(:operatingsystemrelease).value.
153
- should == Facter.fact(:kernelrelease).value
154
- end
155
- end
156
- end
157
-
158
- describe "with operatingsystem reported as Windows" do
159
- require 'facter/util/wmi'
160
- before do
161
- Facter.fact(:kernel).stubs(:value).returns("windows")
162
- end
163
-
164
- {
165
- ['5.2.3790', 1] => "XP",
166
- ['6.0.6002', 1] => "Vista",
167
- ['6.0.6002', 2] => "2008",
168
- ['6.0.6002', 3] => "2008",
169
- ['6.1.7601', 1] => "7",
170
- ['6.1.7601', 2] => "2008 R2",
171
- ['6.1.7601', 3] => "2008 R2",
172
- ['6.2.9200', 1] => "8",
173
- ['6.2.9200', 2] => "2012",
174
- ['6.2.9200', 3] => "2012",
175
- }.each do |os_values, expected_output|
176
- it "should be #{expected_output} with Version #{os_values[0]} and ProductType #{os_values[1]}" do
177
- os = mock('os', :version => os_values[0], :producttype => os_values[1])
178
- Facter::Util::WMI.expects(:execquery).returns([os])
179
- Facter.fact(:operatingsystemrelease).value.should == expected_output
180
- end
181
- end
182
-
183
- {
184
- ['5.2.3790', 2, ""] => "2003",
185
- ['5.2.3790', 2, "R2"] => "2003 R2",
186
- ['5.2.3790', 3, ""] => "2003",
187
- ['5.2.3790', 3, "R2"] => "2003 R2",
188
- }.each do |os_values, expected_output|
189
- it "should be #{expected_output} with Version #{os_values[0]} and ProductType #{os_values[1]} and OtherTypeDescription #{os_values[2]}" do
190
- os = mock('os', :version => os_values[0], :producttype => os_values[1], :othertypedescription => os_values[2])
191
- Facter::Util::WMI.expects(:execquery).returns([os])
192
- Facter.fact(:operatingsystemrelease).value.should == expected_output
193
- end
194
- end
195
-
196
- it "reports '2003' if the WMI method othertypedescription does not exist" do
197
- os = mock('os', :version => '5.2.3790', :producttype => 2)
198
- os.stubs(:othertypedescription).raises(NoMethodError)
199
-
200
- Facter::Util::WMI.expects(:execquery).returns([os])
201
- Facter.fact(:operatingsystemrelease).value.should == '2003'
202
- end
203
-
204
- context "Unknown Windows version" do
205
- before :each do
206
- Facter.fact(:kernelrelease).stubs(:value).returns("X.Y.ZZZZ")
207
- end
208
-
209
- it "should be kernel version value with unknown values " do
210
- os = mock('os', :version => "X.Y.ZZZZ")
211
- Facter::Util::WMI.expects(:execquery).returns([os])
212
- Facter.fact(:operatingsystemrelease).value.should == "X.Y.ZZZZ"
213
- end
214
- end
215
- end
216
-
217
- context "Ubuntu" do
218
- let(:lsbrelease) { 'DISTRIB_ID=Ubuntu\nDISTRIB_RELEASE=10.04\nDISTRIB_CODENAME=lucid\nDISTRIB_DESCRIPTION="Ubuntu 10.04.4 LTS"'}
219
- before :each do
220
- Facter.fact(:kernel).stubs(:value).returns("Linux")
221
- Facter.fact(:operatingsystem).stubs(:value).returns("Ubuntu")
222
- end
223
-
224
- it "Returns only the major and minor version (not patch version)" do
225
- Facter::Util::FileRead.stubs(:read).with("/etc/lsb-release").returns(lsbrelease)
226
- Facter.fact(:operatingsystemrelease).value.should == "10.04"
227
- end
228
- end
229
-
230
- it "uses '/etc/os-release for Cumulus Linux" do
231
- Facter.fact(:kernel).stubs(:value).returns("Linux")
232
- Facter.fact(:operatingsystem).stubs(:value).returns("CumulusLinux")
233
- Facter::Util::Operatingsystem.expects(:os_release).returns({'VERSION_ID' => '1.5.0'})
234
- Facter.fact(:operatingsystemrelease).value.should == "1.5.0"
6
+ let(:os_hash) { { "name" => "SomeOS",
7
+ "family" => "SomeFamily",
8
+ "release" => {
9
+ "major" => "1",
10
+ "minor" => "2",
11
+ "full" => "1.2.3"
12
+ }
13
+ }
14
+ }
15
+
16
+ it "should use the 'full' key of the 'release' key from the 'os' fact" do
17
+ Facter.fact("os").stubs(:value).returns(os_hash)
18
+ Facter.fact(:operatingsystemrelease).value.should eq "1.2.3"
235
19
  end
236
20
  end
@@ -0,0 +1,131 @@
1
+ #! /usr/bin/env ruby
2
+
3
+ require 'spec_helper'
4
+ require 'facter/operatingsystem/base'
5
+ require 'facter/operatingsystem/linux'
6
+
7
+ describe "os" do
8
+ subject { Facter.fact("os") }
9
+ let(:os) { stub 'OS object' }
10
+ let(:lsb_hash) { { "distcodename" => "trusty",
11
+ "distid" => "Ubuntu",
12
+ "distdescription" => "Ubuntu 14.04 LTS",
13
+ "distrelease" => "14.04",
14
+ "release" => "14.04",
15
+ "majdistrelease" => "14"
16
+ }
17
+ }
18
+
19
+ let(:release_hash) { { "major" => 1,
20
+ "minor" => 2,
21
+ "patch" => 3,
22
+ "full" => "1.2.3"
23
+ }
24
+ }
25
+
26
+ describe "in Linux with lsb facts available" do
27
+ before do
28
+ Facter::Operatingsystem::Linux.stubs(:new).returns os
29
+ end
30
+
31
+ before :each do
32
+ Facter.fact(:kernel).stubs(:value).returns("Linux")
33
+ os.expects(:get_operatingsystem).returns("Ubuntu")
34
+ os.expects(:get_osfamily).returns("Debian")
35
+ os.expects(:get_operatingsystemrelease_hash).returns(release_hash)
36
+ os.expects(:has_lsb?).returns(true)
37
+ os.expects(:get_lsb_facts_hash).returns(lsb_hash)
38
+ end
39
+
40
+ it "should include a name key with the operatingsystem name" do
41
+ expect(subject.value["name"]).to eq "Ubuntu"
42
+ end
43
+
44
+ it "should include a family key with the osfamily name" do
45
+ expect(subject.value["family"]).to eq "Debian"
46
+ end
47
+
48
+ it "should include a release key with the OS release" do
49
+ expect(subject.value["release"]["full"]).to eq "1.2.3"
50
+ end
51
+
52
+ it "should include a major key with the major release" do
53
+ expect(subject.value["release"]["major"]).to eq 1
54
+ end
55
+
56
+ it "should include a minor key with the major release" do
57
+ expect(subject.value["release"]["minor"]).to eq 2
58
+ end
59
+
60
+ it "should include a patch key with the patch release" do
61
+ expect(subject.value["release"]["patch"]).to eq 3
62
+ end
63
+
64
+ it "should include a distid key with the distid" do
65
+ expect(subject.value["lsb"]["distid"]).to eq "Ubuntu"
66
+ end
67
+
68
+ it "should include an distcodename key with the codename" do
69
+ expect(subject.value["lsb"]["distcodename"]).to eq "trusty"
70
+ end
71
+
72
+ it "should include an distdescription key with the description" do
73
+ expect(subject.value["lsb"]["distdescription"]).to eq "Ubuntu 14.04 LTS"
74
+ end
75
+
76
+ it "should include an release key with the release" do
77
+ expect(subject.value["lsb"]["release"]).to eq "14.04"
78
+ end
79
+
80
+ it "should include an distrelease key with the release" do
81
+ expect(subject.value["lsb"]["distrelease"]).to eq "14.04"
82
+ end
83
+
84
+ it "should include an majdistrelease key with the major release" do
85
+ expect(subject.value["lsb"]["majdistrelease"]).to eq "14"
86
+ end
87
+
88
+ end
89
+
90
+ describe "in an OS without lsb facts available" do
91
+ before do
92
+ Facter::Operatingsystem::Base.stubs(:new).returns os
93
+ end
94
+
95
+ before :each do
96
+ Facter.fact(:kernel).stubs(:value).returns("Darwin")
97
+ os.expects(:get_operatingsystem).returns("Darwin")
98
+ os.expects(:get_osfamily).returns("Darwin")
99
+ os.expects(:get_operatingsystemrelease_hash).returns(release_hash)
100
+ os.expects(:has_lsb?).returns(false)
101
+ end
102
+
103
+ it "should include a name key with the operatingsystem name" do
104
+ expect(subject.value["name"]).to eq "Darwin"
105
+ end
106
+
107
+ it "should include a family key with the osfamily name" do
108
+ expect(subject.value["family"]).to eq "Darwin"
109
+ end
110
+
111
+ it "should include a release key with the OS release" do
112
+ expect(subject.value["release"]["full"]).to eq "1.2.3"
113
+ end
114
+
115
+ it "should include a major with the major release" do
116
+ expect(subject.value["release"]["major"]).to eq 1
117
+ end
118
+
119
+ it "should include a minor with the minor release" do
120
+ expect(subject.value["release"]["minor"]).to eq 2
121
+ end
122
+
123
+ it "should include a patch with the patch release" do
124
+ expect(subject.value["release"]["patch"]).to eq 3
125
+ end
126
+
127
+ it "should not include an lsb key" do
128
+ expect(subject.value["lsb"]).to be_nil
129
+ end
130
+ end
131
+ end
@@ -3,60 +3,15 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  describe "OS Family fact" do
6
+ let(:os_hash) { { "name" => "SomeOS",
7
+ "family" => "SomeFamily",
8
+ "release" => "1.2.3",
9
+ "releasemajor" => "1",
10
+ }
11
+ }
6
12
 
7
- {
8
- 'Archlinux' => 'Archlinux',
9
- 'SmartOS' => 'Solaris',
10
- 'OpenIndiana' => 'Solaris',
11
- 'OmniOS' => 'Solaris',
12
- 'Nexenta' => 'Solaris',
13
- 'Solaris' => 'Solaris',
14
- 'Ubuntu' => 'Debian',
15
- 'Debian' => 'Debian',
16
- 'LinuxMint' => 'Debian',
17
- 'Gentoo' => 'Gentoo',
18
- 'Fedora' => 'RedHat',
19
- 'Amazon' => 'RedHat',
20
- 'OracleLinux' => 'RedHat',
21
- 'OVS' => 'RedHat',
22
- 'OEL' => 'RedHat',
23
- 'CentOS' => 'RedHat',
24
- 'SLC' => 'RedHat',
25
- 'Scientific' => 'RedHat',
26
- 'CloudLinux' => 'RedHat',
27
- 'PSBM' => 'RedHat',
28
- 'Ascendos' => 'RedHat',
29
- 'XenServer' => 'RedHat',
30
- 'RedHat' => 'RedHat',
31
- 'SLES' => 'Suse',
32
- 'SLED' => 'Suse',
33
- 'OpenSuSE' => 'Suse',
34
- 'SuSE' => 'Suse',
35
- 'Mageia' => 'Mandrake',
36
- 'Mandriva' => 'Mandrake',
37
- 'Mandrake' => 'Mandrake',
38
- }.each do |os,family|
39
- it "should return #{family} on operatingsystem #{os}" do
40
- Facter.fact(:operatingsystem).stubs(:value).returns os
41
- Facter.fact(:osfamily).value.should == family
42
- end
43
- end
44
-
45
- [
46
- 'MeeGo',
47
- 'VMWareESX',
48
- 'Bluewhite64',
49
- 'Slamd64',
50
- 'Slackware',
51
- 'Alpine',
52
- 'ESXi',
53
- 'windows',
54
- 'HP-UX'
55
- ].each do |os|
56
- it "should return the kernel fact on operatingsystem #{os}" do
57
- Facter.fact(:operatingsystem).stubs(:value).returns os
58
- Facter.fact(:kernel).stubs(:value).returns 'random_kernel_fact'
59
- Facter.fact(:osfamily).value.should == 'random_kernel_fact'
60
- end
13
+ it "should use the 'osfamily' key of the 'os' fact" do
14
+ Facter.fact("os").stubs(:value).returns(os_hash)
15
+ Facter.fact(:osfamily).value.should eq "SomeFamily"
61
16
  end
62
17
  end