edestecd / puppet-mariadb

Puppet Module for managing MariaDB
GNU General Public License v3.0
3 stars 21 forks source link

Evaluation Error: Unknown variable: '::service_provider' #15

Closed bittner closed 6 years ago

bittner commented 6 years ago

When running tests over the roles of our control repository that use the mariadb module I get the following error for an unknown variable that refer to params.pp, line 16:

$ pdk test unit
[✔] Preparing to run the unit tests.
[✖] Running unit tests.
  Evaluated 8 tests in 5.733688574 seconds: 2 failures, 0 pending.
[✔] Cleaning up after running unit tests.
failed: rspec: ./spec/classes/role_server_customer_standalone_spec.rb:10: error during compilation: Evaluation Error: Unknown variable: '::service_provider'. at /home/peter.bittner/Development/repos/puppet-control/spec/fixtures/modules/mariadb/manifests/params.pp:16:19 on node peter-pc.comsolit.local
  role::server::customer_standalone on ubuntu-16.04-x86_64 should compile into a catalogue without dependency cycles
  Failure/Error:
        end

        it { is_expected.to compile.with_all_deps }
      end
    end

failed: rspec: ./spec/classes/role_server_customer_standalone_spec.rb:10: error during compilation: Evaluation Error: Unknown variable: '::service_provider'. at /home/peter.bittner/Development/repos/puppet-control/spec/fixtures/modules/mariadb/manifests/params.pp:16:19 on node peter-pc.comsolit.local
  role::server::customer_standalone on debian-8-x86_64 should compile into a catalogue without dependency cycles
  Failure/Error:
        end

        it { is_expected.to compile.with_all_deps }
      end
    end

Where is $service_provider supposed to come from? What is it supposed to contain?

I guess I will simply set it to 'systemd' for the RSpec example on the affected roles to make the tests pass. Do I do the right thing?

bittner commented 6 years ago

See issue #16 for the implementation (full source code) of the rspec test.

edestecd commented 6 years ago

$service_provider is a fact in stdlib: https://github.com/puppetlabs/puppetlabs-stdlib#service_provider

I usually mock it in the spec tests with facts.