1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
|
#! /usr/bin/env ruby
require 'spec_helper'
require 'puppet/configurer'
require 'puppet/configurer/plugin_handler'
describe Puppet::Configurer::PluginHandler do
let(:pluginhandler) { Puppet::Configurer::PluginHandler.new() }
let(:environment) { Puppet::Node::Environment.create(:myenv, []) }
context "server agent version is 5.3.4" do
before :each do
# PluginHandler#load_plugin has an extra-strong rescue clause
# this mock is to make sure that we don't silently ignore errors
Puppet.expects(:err).never
# Server_agent version needs to be at 5.3.4 in order to mount locales
Puppet.push_context({:server_agent_version => "5.3.4"})
end
it "downloads plugins, facts, and locales" do
Puppet::Configurer::Downloader.any_instance.expects(:evaluate).times(3).returns([])
pluginhandler.download_plugins(environment)
end
it "returns downloaded plugin, fact, and locale filenames" do
Puppet::Configurer::Downloader.any_instance.expects(:evaluate).times(3).returns(%w[/a]).then.returns(%w[/b]).then.returns(%w[/c])
expect(pluginhandler.download_plugins(environment)).to match_array(%w[/a /b /c])
end
end
context "server agent version is 5.3.3" do
before :each do
# PluginHandler#load_plugin has an extra-strong rescue clause
# this mock is to make sure that we don't silently ignore errors
Puppet.expects(:err).never
# Server_agent version needs to be at 5.3.4 in order to mount locales
Puppet.push_context({:server_agent_version => "5.3.3"})
end
it "returns downloaded plugin, fact, but not locale filenames" do
Puppet::Configurer::Downloader.any_instance.expects(:evaluate).times(2).returns(%w[/a]).then.returns(%w[/b])
expect(pluginhandler.download_plugins(environment)).to match_array(%w[/a /b])
end
end
context "blank server agent version" do
before :each do
# PluginHandler#load_plugin has an extra-strong rescue clause
# this mock is to make sure that we don't silently ignore errors
Puppet.expects(:err).never
# Server_agent version needs to be at 5.3.4 in order to mount locales
# A blank version will default to 0.0
Puppet.push_context({:server_agent_version => ""})
end
it "returns downloaded plugin, fact, but not locale filenames" do
Puppet::Configurer::Downloader.any_instance.expects(:evaluate).times(2).returns(%w[/a]).then.returns(%w[/b])
expect(pluginhandler.download_plugins(environment)).to match_array(%w[/a /b])
end
end
end
|