Skip to content

Commit

Permalink
Add rspec tests for custom facts
Browse files Browse the repository at this point in the history
  • Loading branch information
bobapple committed Apr 6, 2017
1 parent 5d2b4d3 commit 3499bbe
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 0 deletions.
38 changes: 38 additions & 0 deletions spec/unit/facter/util/fact_icinga2_puppet_hostcert_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
require 'spec_helper'

describe Facter::Util::Fact do
on_supported_os.each do |os, facts|
let :facts do
facts
end

context "#{os} icinga2_puppet_hostcert fact" do
it { expect(Facter.fact(:icinga2_puppet_hostcert).value).to match(/\/ssl\/certs\/.*.pem/) }
end
end
end

describe('icinga2::feature::gelf', :type => :class) do
let(:facts) { {
:kernel => 'Windows',
:architecture => 'x86_64',
:osfamily => 'Windows',
:operatingsystem => 'Windows',
:operatingsystemmajrelease => '2012 R2',
:path => 'C:\Program Files\Puppet Labs\Puppet\puppet\bin;
C:\Program Files\Puppet Labs\Puppet\facter\bin;
C:\Program Files\Puppet Labs\Puppet\hiera\bin;
C:\Program Files\Puppet Labs\Puppet\mcollective\bin;
C:\Program Files\Puppet Labs\Puppet\bin;
C:\Program Files\Puppet Labs\Puppet\sys\ruby\bin;
C:\Program Files\Puppet Labs\Puppet\sys\tools\bin;
C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;
C:\Windows\System32\WindowsPowerShell\v1.0\;
C:\ProgramData\chocolatey\bin;',
} }

context "Windows 2012 R2 icinga2_puppet_hostcert fact" do
it { expect(Facter.fact(:icinga2_puppet_hostcert).value).to match(/\/ssl\/certs\/.*.pem/) }
end

end
38 changes: 38 additions & 0 deletions spec/unit/facter/util/fact_icinga2_puppet_hostprivkey_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
require 'spec_helper'

describe Facter::Util::Fact do
on_supported_os.each do |os, facts|
let :facts do
facts
end

context "#{os} icinga2_puppet_hostprivkey fact" do
it { expect(Facter.fact(:icinga2_puppet_hostprivkey).value).to match(/\/ssl\/private_keys\/.*.pem/) }
end
end
end

describe('icinga2::feature::gelf', :type => :class) do
let(:facts) { {
:kernel => 'Windows',
:architecture => 'x86_64',
:osfamily => 'Windows',
:operatingsystem => 'Windows',
:operatingsystemmajrelease => '2012 R2',
:path => 'C:\Program Files\Puppet Labs\Puppet\puppet\bin;
C:\Program Files\Puppet Labs\Puppet\facter\bin;
C:\Program Files\Puppet Labs\Puppet\hiera\bin;
C:\Program Files\Puppet Labs\Puppet\mcollective\bin;
C:\Program Files\Puppet Labs\Puppet\bin;
C:\Program Files\Puppet Labs\Puppet\sys\ruby\bin;
C:\Program Files\Puppet Labs\Puppet\sys\tools\bin;
C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;
C:\Windows\System32\WindowsPowerShell\v1.0\;
C:\ProgramData\chocolatey\bin;',
} }

context "Windows 2012 R2 icinga2_puppet_hostprivkey fact" do
it { expect(Facter.fact(:icinga2_puppet_hostprivkey).value).to match(/\/ssl\/private_keys\/.*.pem/) }
end

end
38 changes: 38 additions & 0 deletions spec/unit/facter/util/fact_icinga2_puppet_localcacert_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
require 'spec_helper'

describe Facter::Util::Fact do
on_supported_os.each do |os, facts|
let :facts do
facts
end

context "#{os} icinga2_puppet_localcacert fact" do
it { expect(Facter.fact(:icinga2_puppet_localcacert).value).to match(/\/ssl\/certs\/.*.pem/) }
end
end
end

describe('icinga2::feature::gelf', :type => :class) do
let(:facts) { {
:kernel => 'Windows',
:architecture => 'x86_64',
:osfamily => 'Windows',
:operatingsystem => 'Windows',
:operatingsystemmajrelease => '2012 R2',
:path => 'C:\Program Files\Puppet Labs\Puppet\puppet\bin;
C:\Program Files\Puppet Labs\Puppet\facter\bin;
C:\Program Files\Puppet Labs\Puppet\hiera\bin;
C:\Program Files\Puppet Labs\Puppet\mcollective\bin;
C:\Program Files\Puppet Labs\Puppet\bin;
C:\Program Files\Puppet Labs\Puppet\sys\ruby\bin;
C:\Program Files\Puppet Labs\Puppet\sys\tools\bin;
C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;
C:\Windows\System32\WindowsPowerShell\v1.0\;
C:\ProgramData\chocolatey\bin;',
} }

context "Windows 2012 R2 icinga2_puppet_localcacert fact" do
it { expect(Facter.fact(:icinga2_puppet_localcacert).value).to match(/\/ssl\/certs\/.*.pem/) }
end

end

0 comments on commit 3499bbe

Please sign in to comment.