File: plugin_handler_spec.rb

package info (click to toggle)
puppet 4.8.2-5
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 20,736 kB
  • ctags: 14,616
  • sloc: ruby: 236,754; xml: 1,586; sh: 1,178; lisp: 299; sql: 103; yacc: 72; makefile: 52
file content (42 lines) | stat: -rw-r--r-- 1,559 bytes parent folder | download | duplicates (2)
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
#! /usr/bin/env ruby
require 'spec_helper'
require 'puppet/configurer'
require 'puppet/configurer/plugin_handler'

describe Puppet::Configurer::PluginHandler do
  let(:factory)       { Puppet::Configurer::DownloaderFactory.new }
  let(:pluginhandler) { Puppet::Configurer::PluginHandler.new(factory) }
  let(:environment)   { Puppet::Node::Environment.create(:myenv, []) }

  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
  end

  context "when external facts are supported" do
    before :each do
      Puppet.features.stubs(:external_facts?).returns(true)
    end

    it "downloads plugins and facts" do
      plugin_downloader = stub('plugin-downloader', :evaluate => [])
      facts_downloader = stub('facts-downloader', :evaluate => [])

      factory.expects(:create_plugin_downloader).returns(plugin_downloader)
      factory.expects(:create_plugin_facts_downloader).returns(facts_downloader)

      pluginhandler.download_plugins(environment)
    end

    it "returns downloaded plugin and fact filenames" do
      plugin_downloader = stub('plugin-downloader', :evaluate => %w[/a])
      facts_downloader = stub('facts-downloader', :evaluate => %w[/b])

      factory.expects(:create_plugin_downloader).returns(plugin_downloader)
      factory.expects(:create_plugin_facts_downloader).returns(facts_downloader)

      expect(pluginhandler.download_plugins(environment)).to match_array(%w[/a /b])
    end
  end
end