I think I figured it out.... two things actually....

1. The PDK auto-generated testing files all use rspec-puppet-facts, which 
uses facterdb internally, which does not know anything about Solaris 10. 
Even though that is a supported platform for Puppet....

Removing "require 'rspec-puppet-facts'" and "include RspecPuppetFacts" from 
the spec_helper.rb file, as well as changing the spec/classes/etc_system.rb 
file to list out facts for each test context, and not loop on data from the 
metadata.json file makes the testing work as expected.    I suspect this 
will all work as advertised for RedHat modules, which is the vast majority 
of what I need anyway, it just happened that I needed to make an update to 
a Solaris module when I got pdk installed! 

2. I had my spec/classes/  test file named .pp instead of .rb.    oops!



Bill



On Monday, February 19, 2018 at 9:58:13 AM UTC-5, Bill Sirinek wrote:
>
> I've converted a simple module to use PDK, but the testing is not working. 
> The module is specifically for Solaris. The module is a very simple one 
> that just edits /etc/system, called etc_system.
>
> In fact, the test is not even being seen. Here's the output I get, along 
> with the contents of some files. I have tried using as much of the default 
> as I can and it's still not working.
>
> I'm using pdk 1.3.2 on OSX Sierra 10.12.6
>
> Thanks
>
> Bill
>
>
>
> mylaptop:etc_system bsirinek$ *pdk test unit **--**list*
> No unit test files with examples were found.
>
>
> mylaptop:etc_system bsirinek$ *pdk test unit*
> [✔] Preparing to run the unit tests.
> [✔] Running unit tests.
> No examples found.
>   Evaluated 0 tests in 0.000681 seconds: 0 failures, 0 pending.
> [✔] Cleaning up after running unit tests.
>
> mylaptop:etc_system bsirinek$ *pdk test unit **--**debug*
> pdk (DEBUG): Checking for missing Gemfile dependencies.
> pdk (DEBUG): Using 'private/ruby/2.1.9/bin/bundle' from PDK package.
> pdk (DEBUG): Executing '/opt/puppetlabs/pdk/private/ruby/2.1.9/bin/bundle 
> check 
> --gemfile=/Users/bsirinek/git/puppet-enterprise/modules/etc_system/Gemfile'
> pdk (DEBUG): Command environment: GEM_HOME is 
> '/Users/bsirinek/.pdk/cache/ruby/2.1.0' and GEM_PATH is 
> '/opt/puppetlabs/pdk/share/cache/ruby/2.1.0'
> pdk (DEBUG): Execution of '/opt/puppetlabs/pdk/private/ruby/2.1.9/bin/bundle 
> check 
> --gemfile=/Users/bsirinek/git/puppet-enterprise/modules/etc_system/Gemfile' 
> complete (duration: 0.57311s; exit code: 0)
> pdk (DEBUG): Executing 
> '/Users/bsirinek/git/puppet-enterprise/modules/etc_system/bin/rake 
> spec_prep'
> pdk (DEBUG): Command environment: GEM_HOME is 
> '/Users/bsirinek/.pdk/cache/ruby/2.1.0' and GEM_PATH is 
> '/opt/puppetlabs/pdk/share/cache/ruby/2.1.0'
> pdk (DEBUG): Execution of 
> '/Users/bsirinek/git/puppet-enterprise/modules/etc_system/bin/rake 
> spec_prep' complete (duration: 2.209869s; exit code: 0)
> pdk (DEBUG): Executing 
> '/Users/bsirinek/git/puppet-enterprise/modules/etc_system/bin/rake 
> spec[]'
> pdk (DEBUG): Command environment: GEM_HOME is 
> '/Users/bsirinek/.pdk/cache/ruby/2.1.0' and GEM_PATH is 
> '/opt/puppetlabs/pdk/share/cache/ruby/2.1.0'
> pdk (DEBUG): Execution of 
> '/Users/bsirinek/git/puppet-enterprise/modules/etc_system/bin/rake 
> spec[]' complete (duration: 2.717679s; exit code: 0)
> No examples found.
>   Evaluated 0 tests in 0.000707 seconds: 0 failures, 0 pending.
> pdk (DEBUG): Executing 
> '/Users/bsirinek/git/puppet-enterprise/modules/etc_system/bin/rake 
> spec_clean'
> pdk (DEBUG): Command environment: GEM_HOME is 
> '/Users/bsirinek/.pdk/cache/ruby/2.1.0' and GEM_PATH is 
> '/opt/puppetlabs/pdk/share/cache/ruby/2.1.0'
> pdk (DEBUG): Execution of 
> '/Users/bsirinek/git/puppet-enterprise/modules/etc_system/bin/rake 
> spec_clean' complete (duration: 2.247794s; exit code: 0)
>
>
> mylaptop:etc_system bsirinek$
>
>
> spec/spec_helper.rb:
>
> require 'puppetlabs_spec_helper/module_spec_helper'
> require 'rspec-puppet-facts'
> include RspecPuppetFacts
>
>
> default_facts = {
>   puppetversion: Puppet.version,
>   facterversion: Facter.version,
> }
>
>
> default_facts_path = File.expand_path(File.join(File.dirname(__FILE__), 
> 'default_facts.yml'))
> default_module_facts_path = File.expand_path(File.join(File.dirname(
> __FILE__), 'default_module_facts.yml'))
>
>
> if File.exist?(default_facts_path) && File.readable?(default_facts_path)
>   default_facts.merge!(YAML.safe_load(File.read(default_facts_path)))
> end
>
>
> if File.exist?(default_module_facts_path) && File.readable?(
> default_module_facts_path)
>   default_facts.merge!(YAML.safe_load(File.read(default_module_facts_path
> )))
> end
>
>
> RSpec.configure do |c|
>   c.default_facts = default_facts
> end
>
>
>
> spec/default_facts.yml:
>
> # Use default_module_facts.yml for module specific facts.
> #
> # Facts specified here will override the values provided by 
> rspec-puppet-facts.
> ---
> concat_basedir: "/tmp"
> ipaddress: "172.16.254.254"
> is_pe: false
> macaddress: "AA:AA:AA:AA:AA:AA"
>
>
>
> spec/classes/etc_system_spec.pp:
>
> require 'spec_helper'
>
>
> describe 'etc_system' do
>   on_supported_os.each do |os, os_facts|
>     context "on #{os}" do
>       let(:facts) { os_facts }
>
>
>       it { is_expected.to compile }
>     end
>   end
> end
>
>
>
> metadata.json:
>
>
> {
>   "name": "bsirinek-etc_system",
>   "version": "0.1.0",
>   "author": "Bill Sirinek",
>   "summary": "Manage settings in the Solaris /etc/system file",
>   "license": "proprietary",
>   "source": "https://ourinternalgitsite/etc_system.git";,
>   "issues_url": "https://ourissuewebsite";,
>   "dependencies": [
>
>
>   ],
>   "operatingsystem_support": [
>     {
>       "operatingsystem": "Solaris",
>       "operatingsystemrelease": [
>         "10_u8"
>       ]
>     },
>   ],
>   "requirements": [
>     {
>       "name": "puppet",
>       "version_requirement": ">= 3.7.0 < 6.0.0"
>     }
>   ],
>   "pdk-version": "1.3.2",
>   "template-url": 
> "file:///opt/puppetlabs/pdk/share/cache/pdk-templates.git",
>   "template-ref": "1.3.2-0-g07678c8"
> }
>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/63158e4e-dfb6-4d49-af5f-c65287511425%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to