Add support for OpenBSD, and also add some regression tests.
Add info about OpenBSD support to README.md and metadata.json Add a note about OpenBSD java_version fact to README.markdown. Fixup wording on context in one of the java patch level regression tests. No mentioning of OpenBSD in metdata.json Cleanup wording of context as suggested by @elyscape update contexts as suggested by @elyscape
This commit is contained in:
@@ -17,8 +17,8 @@ describe Facter::Util::Fact do
|
||||
end
|
||||
end
|
||||
|
||||
context "if java is installed" do
|
||||
context 'returns java patch version extracted from java_version fact' do
|
||||
context "if java is not installed" do
|
||||
context 'returns nil' do
|
||||
before :each do
|
||||
Facter.fact(:java_version).stubs(:value).returns(nil)
|
||||
end
|
||||
@@ -28,4 +28,4 @@ describe Facter::Util::Fact do
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -7,23 +7,59 @@ describe Facter::Util::Fact do
|
||||
|
||||
describe "java_version" do
|
||||
context 'returns java version when java present' do
|
||||
it do
|
||||
java_version_output = <<-EOS
|
||||
context 'on OpenBSD' do
|
||||
before do
|
||||
Facter.fact(:operatingsystem).stubs(:value).returns("OpenBSD")
|
||||
end
|
||||
let(:facts) { {:operatingsystem => 'OpenBSD'} }
|
||||
it do
|
||||
java_version_output = <<-EOS
|
||||
openjdk version "1.7.0_71"
|
||||
OpenJDK Runtime Environment (build 1.7.0_71-b14)
|
||||
OpenJDK 64-Bit Server VM (build 24.71-b01, mixed mode)
|
||||
EOS
|
||||
Facter::Util::Resolution.expects(:which).with("java").returns('/usr/local/jdk-1.7.0/jre/bin/java')
|
||||
Facter::Util::Resolution.expects(:exec).with("java -Xmx8m -version 2>&1").returns(java_version_output)
|
||||
Facter.value(:java_version).should == "1.7.0_71"
|
||||
end
|
||||
end
|
||||
context 'on other systems' do
|
||||
before do
|
||||
Facter.fact(:operatingsystem).stubs(:value).returns("MyOS")
|
||||
end
|
||||
let(:facts) { {:operatingsystem => 'MyOS'} }
|
||||
it do
|
||||
java_version_output = <<-EOS
|
||||
java version "1.7.0_71"
|
||||
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
|
||||
Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)
|
||||
EOS
|
||||
Facter::Util::Resolution.expects(:which).with("java").returns(true)
|
||||
Facter::Util::Resolution.expects(:exec).with("java -Xmx8m -version 2>&1").returns(java_version_output)
|
||||
Facter.value(:java_version).should == "1.7.0_71"
|
||||
EOS
|
||||
Facter::Util::Resolution.expects(:exec).with("java -Xmx8m -version 2>&1").returns(java_version_output)
|
||||
Facter.value(:java_version).should == "1.7.0_71"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'returns nil when java not present' do
|
||||
it do
|
||||
Facter::Util::Resolution.stubs(:exec)
|
||||
Facter::Util::Resolution.expects(:which).with("java").returns(false)
|
||||
Facter.value(:java_version).should be_nil
|
||||
context 'on OpenBSD' do
|
||||
before do
|
||||
Facter.fact(:operatingsystem).stubs(:value).returns("OpenBSD")
|
||||
end
|
||||
let(:facts) { {:operatingsystem => 'OpenBSD'} }
|
||||
it do
|
||||
Facter::Util::Resolution.stubs(:exec)
|
||||
Facter.value(:java_version).should be_nil
|
||||
end
|
||||
end
|
||||
context 'on other systems' do
|
||||
before do
|
||||
Facter.fact(:operatingsystem).stubs(:value).returns("MyOS")
|
||||
end
|
||||
let(:facts) { {:operatingsystem => 'MyOS'} }
|
||||
it do
|
||||
Facter::Util::Resolution.expects(:which).with("java").returns(false)
|
||||
Facter.value(:java_version).should be_nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user