diff --git a/.fixtures.yml b/.fixtures.yml index 7fa5bb4..4cc9072 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -1,10 +1,13 @@ fixtures: repositories: - "puppi": "git://github.com/example42/puppi.git" - "monitor": "git://github.com/example42/puppet-monitor.git" - "firewall": "git://github.com/example42/puppet-firewall.git" - "iptables": "git://github.com/example42/puppet-iptables.git" - "concat": "git://github.com/example42/puppet-concat.git" + concat: + repo: 'https://github.com/puppetlabs/puppetlabs-concat.git' + ref: '2.1.0' + puppi: + repo: 'https://github.com/example42/puppi.git' + ref: 'v2.1.13' + stdlib: + repo: 'https://github.com/puppetlabs/puppetlabs-stdlib.git' + ref: '4.6.0' symlinks: - "java": "#{source_dir}" - + java: "#{source_dir}" diff --git a/Gemfile b/Gemfile index be1c34c..9d19ada 100644 --- a/Gemfile +++ b/Gemfile @@ -1,18 +1,32 @@ source 'https://rubygems.org' -puppetversion = ENV['PUPPET_VERSION'] +if puppetversion = ENV['PUPPET_VERSION'] + gem 'puppet', puppetversion, :require => false +else + gem 'puppet', :require => false +end -is_ruby18 = RUBY_VERSION.start_with? '1.8' +gem 'metadata-json-lint' +gem 'puppetlabs_spec_helper', '>= 1.1.1' +gem 'facter', '>= 1.7.0' +gem 'rspec-puppet' +gem 'puppet-lint', :git => 'https://github.com/rodjek/puppet-lint.git' +gem 'puppet-lint-absolute_classname-check' +gem 'puppet-lint-alias-check' +gem 'puppet-lint-file_ensure-check' +gem 'puppet-lint-file_source_rights-check' +gem 'puppet-lint-leading_zero-check' +gem 'puppet-lint-spaceship_operator_without_tag-check' +gem 'puppet-lint-trailing_comma-check' +gem 'puppet-lint-unquoted_string-check' +gem 'puppet-lint-variable_contains_upcase' -if is_ruby18 - gem 'rspec', "~> 3.1.0", :require => false - gem 'rake', '~> 10.5.0', :require => false +# rspec must be v2 for ruby 1.8.7 +if RUBY_VERSION >= '1.8.7' and RUBY_VERSION < '1.9' + # rake >=11 does not support ruby 1.8.7 + gem 'rspec', '~> 2.0' + gem 'rake', '~> 10.0' end -gem 'puppet', puppetversion, :require => false -gem 'puppet-lint' -gem 'puppetlabs_spec_helper', '>= 0.1.0' -gem 'rspec-puppet' -gem 'metadata-json-lint' group :development do gem 'puppet-blacksmith' diff --git a/manifests/init.pp b/manifests/init.pp index 2de6b57..f252327 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -29,6 +29,10 @@ default => 'present', } + validate_absolute_path($java_home_base) + + validate_string($version) + $headless_suffix = $java::bool_headless ? { true => '-headless', default => '', diff --git a/manifests/install.pp b/manifests/install.pp index f4bdf3f..e9d8693 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -58,7 +58,7 @@ case $install { - package: { + 'package': { $headless_suffix = $bool_headless ? { true => '-headless', @@ -86,7 +86,7 @@ /(?i:Solaris)/ => $::operatingsystemmajrelease ? { '10' => "CSWjdk${version}", '11' => "jdk-${version}", - '5' => "jdk", + '5' => 'jdk', }, default => fail("OperatingSystem ${::operatingsystem} not supported"), } @@ -108,7 +108,7 @@ } - source: { + 'source': { if (!$install_source) { fail('Required arguement: install_source') } diff --git a/metadata.json b/metadata.json index e16e237..222385d 100644 --- a/metadata.json +++ b/metadata.json @@ -59,11 +59,11 @@ }, { "name": "example42/puppi", - "version_requirement": ">= 2.0.0" + "version_requirement": ">= 2.0.0 < 3.0.0" }, { "name": "puppetlabs/concat", - "version_requirement": ">= 1.0.0" + "version_requirement": ">= 1.0.0 < 2.0.0" } ] } diff --git a/spec/classes/init_spec.rb b/spec/classes/init_spec.rb new file mode 100644 index 0000000..2cdf5ba --- /dev/null +++ b/spec/classes/init_spec.rb @@ -0,0 +1,60 @@ +require 'spec_helper' + + describe 'java' do + let(:facts) do + { :osfamily => 'Debian', + :operatingsystemmajrelease => '6', + } + end + + context 'with defaults for all parameters' do + it { should contain_class('java') } + + it { should compile.with_all_deps } + end + + describe 'variable type and content validations' do + let(:validation_params) do + { + #:param => 'value', + } + end + + validations = { + 'absolute_path' => { + :name => ['java_home_base'], + :valid => ['/usr/lib/jvm'], + :invalid => ['invalid',3,2.42,['array'],a={'ha'=>'sh'}], + :message => 'is not an absolute path', + }, + 'version' => { + :name => ['version'] , + :valid => ['6'], + :invalid => [['array'],a={'ha'=>'sh'}, true], + :message => 'is not a string', + }, + } + + validations.sort.each do |type, var| + var[:name].each do |var_name| + var[:valid].each do |valid| + context "with #{var_name} (#{type}) set to valid #{valid} (as #{valid.class})" do + let(:params) { validation_params.merge({ :"#{var_name}" => valid, }) } + it { should compile } + end + end + + var[:invalid].each do |invalid| + context "with #{var_name} (#{type}) set to invalid #{invalid} (as #{invalid.class})" do + let(:params) { validation_params.merge({ :"#{var_name}" => invalid, }) } + it 'should fail' do + expect do + should contain_class(subject) + end.to raise_error(Puppet::Error, /#{var[:message]}/) + end + end + end + end # var[:name].each + end # validations.sort.each + end # describe +end