Sha256: fc3bfdcc014b1037a809a198dab2f534a1ff3720cebe9f82e333a555c9fcc921
Contents?: true
Size: 1.9 KB
Versions: 52
Compression:
Stored size: 1.9 KB
Contents
require 'spec_helper' require 'puppet/face' require 'puppet/indirector/facts/facter' require 'puppet/indirector/facts/rest' describe Puppet::Face[:facts, '0.0.1'] do describe "#find" do it { is_expected.to be_action :find } end describe '#upload' do let(:model) { Puppet::Node::Facts } let(:test_data) { model.new('puppet.node.test', {test_fact: 'test value'}) } let(:facter_terminus) { model.indirection.terminus(:facter) } let(:rest_terminus) { model.indirection.terminus(:rest) } before(:each) do Puppet.settings.parse_config(<<-CONF) [main] server=puppet.server.invalid certname=puppet.node.invalid [agent] server=puppet.server.test node_name_value=puppet.node.test CONF # Faces start in :user run mode Puppet.settings.preferred_run_mode = :user allow(facter_terminus).to receive(:find).with(instance_of(Puppet::Indirector::Request)).and_return(test_data) allow(rest_terminus).to receive(:save).with(instance_of(Puppet::Indirector::Request)).and_return(nil) end it { is_expected.to be_action :upload } it "finds facts from terminus_class :facter" do expect(facter_terminus).to receive(:find).with(instance_of(Puppet::Indirector::Request)).and_return(test_data) subject.upload end it "saves facts to terminus_class :rest" do expect(rest_terminus).to receive(:save).with(instance_of(Puppet::Indirector::Request)).and_return(nil) subject.upload end it "uses settings from the agent section of puppet.conf" do expect(facter_terminus).to receive(:find).with(have_attributes(key: 'puppet.node.test')).and_return(test_data) subject.upload end it "logs the name of the server that received the upload" do subject.upload expect(@logs).to be_any {|log| log.level == :notice && log.message =~ /Uploading facts for '.*' to: 'puppet\.server\.test'/} end end end
Version data entries
52 entries across 52 versions & 1 rubygems