e9370fee7b
This patch includes some very basic and initial unit testing using rspec-puppet and for the case of facts, just normal rspec. I've taken a very light approach here as rspec-puppet can be quite combinatorial when one gets carried away. For now I've just added basic compile failure detection effectively for classes and defined resources. As we continue to work on the code and find regressions this work can be expanded. For facts and functions I've also taken a basic approach for now. One little thing I did change, was the strange string that the fact returns when the default version is undefined. Instead of an error message I've just returned the string 'unknown' which is more in line with other facts I've seen in the wild, and to be quite honest 'unknown' is fairly self-explantory. Since a fact isn't an error reporting message this seemed more appropriate, and looked nicer in the rspec test. As far as travis-ci support, I've added the same configuration that @jmmcune came up with for stdlib which is pretty light and reasonable standard now we propogated that to 4 or so other modules in the puppetlabs/ namespace. It should work out of the box. Signed-off-by: Ken Barber <ken@bob.sh>
72 lines
1.5 KiB
Ruby
72 lines
1.5 KiB
Ruby
def get_debianfamily_postgres_version
|
|
case Facter.value('operatingsystem')
|
|
when "Debian"
|
|
get_debian_postgres_version()
|
|
when "Ubuntu"
|
|
get_ubuntu_postgres_version()
|
|
else
|
|
nil
|
|
end
|
|
end
|
|
|
|
def get_debian_postgres_version
|
|
case Facter.value('operatingsystemrelease')
|
|
# TODO: add more debian versions or better logic here
|
|
when /^6\./
|
|
"8.4"
|
|
when /^wheezy/, /^7\./
|
|
"9.1"
|
|
else
|
|
nil
|
|
end
|
|
end
|
|
|
|
def get_ubuntu_postgres_version
|
|
case Facter.value('operatingsystemrelease')
|
|
# TODO: add more ubuntu versions or better logic here
|
|
when "12.10"
|
|
"9.1"
|
|
when "12.04"
|
|
"9.1"
|
|
when "10.04"
|
|
"8.4"
|
|
else
|
|
nil
|
|
end
|
|
end
|
|
|
|
def get_redhatfamily_postgres_version
|
|
case Facter.value('operatingsystemrelease')
|
|
when /^6\./
|
|
"8.4"
|
|
when /^5\./
|
|
"8.1"
|
|
else
|
|
nil
|
|
end
|
|
end
|
|
|
|
Facter.add("postgres_default_version") do
|
|
setcode do
|
|
result =
|
|
case Facter.value('osfamily')
|
|
when 'RedHat'
|
|
get_redhatfamily_postgres_version()
|
|
when 'Linux'
|
|
get_redhatfamily_postgres_version()
|
|
when 'Debian'
|
|
get_debianfamily_postgres_version()
|
|
else
|
|
nil
|
|
end
|
|
|
|
# TODO: not sure if this is really a great idea, but elsewhere in the code
|
|
# it is useful to be able to distinguish between the case where the fact
|
|
# does not exist at all (e.g., if pluginsync is not enabled), and the case
|
|
# where the fact is not known for the OS in question.
|
|
if result == nil
|
|
result = 'unknown'
|
|
end
|
|
result
|
|
end
|
|
end
|