Quantcast
Channel: Ask Puppet: Puppet DevOps Q&A Community - RSS feed
Viewing all articles
Browse latest Browse all 257

"" is not a Hash. It looks to be a String

$
0
0
I have **init.pp** as below: class mymodule { include mymodule::users include mymodule::install include mymodule::config include mymodule::service Class[mymodule::users] -> Class[mymodule::install] -> Class[mymodule::config] -> Class[mymodule::service] } I have **install.pp** as below: class mymodule::install ( $artifacts = undef, ) inherits mymodule::params { validate_hash($artifacts) create_resources('different_module::artifact', $artifacts) } And I am creating specs for these classes as below: **init_spec.pp** require 'spec_helper' require 'hiera' describe 'mymodule', :type => :class do let(:pre_condition) { ' include mymodule::install include mymodule::users include mymodule::service include mymodule::config ' } it { should contain_class('mymodule') } end **install_spec.pp** require 'spec_helper' require 'hiera' describe 'mymodule::install', :type => :class do let(:pre_condition) {'include different_module' } let(:hiera_config) { 'spec/fixtures/hiera/hiera.yaml' } hiera = Hiera.new(:config => 'spec/fixtures/hiera/hiera.yaml') artifacts = hiera.lookup('mymodule::install::artifacts', nil, nil) let(:params) { { :artifacts => artifacts } } it { should contain_class('mymodule::install') } it { should contain_different_module__artifact('mymodule') } } **spec/fixtures/hiera/hiera.yaml** --- :backends: - yaml :yaml: :datadir: spec/fixtures/hieradata :hierarchy: - common **spec/fixtures/hieradata/common.yaml** mymodule::install::artifacts: mymodule: groupid: 'au.com.org.app' artifactid: 'mymodule' version: 'r1.0' type: 'tgz' destination: '/tmp/mymodule_r1.0.tar.gz' timeout: '0' When I run rspec I am getting the below error: "" is not a Hash. It looks to be a String at /tmp/mymodule/spec/fixtures/modules/mymodule/manifests/install.pp:6 EDIT: When I add Alex's fail statement before `validate_hash` all the specs have been failed. Interestingly, I can see the below, only for `should contain_class`, it is empty: 1) mymodule should contain Class[mymodule] Failure/Error: it { should contain_class('mymodule') } Puppet::Error: I got for artifacts at /tmp/mymodule/spec/fixtures/modules/mymodule/manifests/install.pp:6 on node debian-vm.localdomain And for other specs I can see the value of artifacts as below: 3) mymodule::install should contain Class[mymodule::install] Failure/Error: it { should contain_class('mymodule::install') } Puppet::Error: I got {"mymodule"=>{"groupid"=>"au.com.env.app", "artifactid"=>"mymodule", "version"=>"r4", "type"=>"tgz", "destination"=>"/tmp/mymodule_r49.tar.gz", "timeout"=>"0"}} for artifacts at /tmp/mymodule_r4/spec/fixtures/modules/mymodule_r4/manifests/install.pp:6 on node debian-vm.localdomain

Viewing all articles
Browse latest Browse all 257

Trending Articles