puppetlabs / pdk

The shortest path to better modules: Puppet Development Kit; Download:
https://puppet.com/download-puppet-development-kit
Apache License 2.0
225 stars 106 forks source link

'unknown type yumrepo' during 'pdk test unit' #607

Closed Felixoid closed 5 years ago

Felixoid commented 5 years ago

Describe the bug Unit tests complain Error while evaluating a Resource Statement, Unknown resource type: 'yumrepo' with PDK version 1.7.1

To Reproduce

pdk new module --skip-interview test_rspec && cd test_rspec
cat << EOF >manifests/init.pp
# class
class test_rspec {
    yumrepo { 'repo name':
        descr   => 'repo name',
        enabled => 1,
    }
}
EOF
mkdir -p spec/classes
cat <<EOF> spec/classes/init_spec.rb
require 'spec_helper'

describe 'test_rspec' do
  let(:facts) do
    {
      os: {
        family: 'RedHat',
        name: 'CentOS',
        release: {
          full: '7.4.1708',
          major: '7',
          minor: '4',
        },
      },
      osfamily: 'RedHat',
      operatingsystem: 'Centos',
    }
  end

  it do
    is_expected.to compile
  end
end
EOF
pdk test unit
pdk (INFO): Module 'test_rspec' generated at path '/tmp/test_rspec', from template 'file:///opt/puppetlabs/pdk/share/cache/pdk-templates.git'.
pdk (INFO): In your module directory, add classes with the 'pdk new class' command.
pdk (INFO): Using Ruby 2.5.1
pdk (INFO): Using Puppet 6.0.2
[✔] Preparing to run the unit tests.
[✖] Running unit tests.
  Evaluated 1 tests in 0.075255545 seconds: 1 failures, 0 pending.
failed: rspec: ./spec/classes/init_spec.rb:20: error during compilation: Evaluation Error: Error while evaluating a Resource Statement, Unknown resource type: 'yumrepo' (file: /home/felixoid/OPT/Felixoid/github/innogames/test-rspec/test_rspec/spec/fixtures/modules/test_rspec/manifests/init.pp, line: 3, column: 5) on node ig-fel
  test_rspec should compile into a catalogue without dependency cycles
  Failure/Error:
    end

    it do
      is_expected.to compile
    end

Expected behavior yumrepo is suppose to be a part of puppet, I would expect to have this resource defined.

Additional context

Felixoid commented 5 years ago

So, right after reporting everything worked with pdk test unit --puppet-version=5.4. Then I've realized on https://puppet.com/docs/puppet/6.0/type.html that yumrepo was moved into separated package on Forge. Thank you for attention. Closed