puppet 4.7.1-universal-darwin → 4.8.0-universal-darwin
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of puppet might be problematic. Click here for more details.
- data/Gemfile +0 -3
- data/MAINTAINERS +76 -0
- data/README.md +0 -6
- data/Rakefile +2 -2
- data/lib/puppet/agent.rb +3 -3
- data/lib/puppet/application/apply.rb +1 -1
- data/lib/puppet/configurer.rb +2 -2
- data/lib/puppet/data_providers.rb +1 -0
- data/lib/puppet/data_providers/data_adapter.rb +1 -0
- data/lib/puppet/data_providers/data_function_support.rb +1 -0
- data/lib/puppet/data_providers/function_env_data_provider.rb +1 -0
- data/lib/puppet/data_providers/function_module_data_provider.rb +1 -0
- data/lib/puppet/data_providers/hiera_config.rb +1 -0
- data/lib/puppet/data_providers/hiera_env_data_provider.rb +1 -0
- data/lib/puppet/data_providers/hiera_interpolate.rb +1 -0
- data/lib/puppet/data_providers/hiera_module_data_provider.rb +1 -0
- data/lib/puppet/data_providers/hiera_support.rb +1 -2
- data/lib/puppet/data_providers/json_data_provider_factory.rb +2 -0
- data/lib/puppet/data_providers/yaml_data_provider_factory.rb +2 -0
- data/lib/puppet/defaults.rb +20 -1
- data/lib/puppet/environments.rb +5 -2
- data/lib/puppet/face/catalog.rb +1 -1
- data/lib/puppet/face/epp.rb +57 -11
- data/lib/puppet/face/module/install.rb +6 -6
- data/lib/puppet/functions.rb +23 -24
- data/lib/puppet/functions/alert.rb +14 -0
- data/lib/puppet/functions/binary_file.rb +25 -0
- data/lib/puppet/functions/break.rb +22 -0
- data/lib/puppet/functions/contain.rb +33 -0
- data/lib/puppet/functions/crit.rb +14 -0
- data/lib/puppet/functions/debug.rb +14 -0
- data/lib/puppet/functions/emerg.rb +14 -0
- data/lib/puppet/functions/epp.rb +1 -1
- data/lib/puppet/functions/err.rb +14 -0
- data/lib/puppet/functions/find_file.rb +31 -0
- data/lib/puppet/functions/include.rb +21 -0
- data/lib/puppet/functions/info.rb +14 -0
- data/lib/puppet/functions/new.rb +1 -1
- data/lib/puppet/functions/next.rb +23 -0
- data/lib/puppet/functions/notice.rb +14 -0
- data/lib/puppet/functions/regsubst.rb +12 -16
- data/lib/puppet/functions/require.rb +37 -0
- data/lib/puppet/functions/return.rb +22 -0
- data/lib/puppet/functions/strftime.rb +35 -0
- data/lib/puppet/functions/warning.rb +14 -0
- data/lib/puppet/generate/models/type/type.rb +4 -0
- data/lib/puppet/generate/templates/type/pcore.erb +2 -1
- data/lib/puppet/indirector/face.rb +6 -1
- data/lib/puppet/network/http/error.rb +2 -2
- data/lib/puppet/network/http/handler.rb +2 -2
- data/lib/puppet/node/environment.rb +11 -0
- data/lib/puppet/parser/ast.rb +5 -0
- data/lib/puppet/parser/ast/pops_bridge.rb +17 -4
- data/lib/puppet/parser/compiler.rb +29 -1
- data/lib/puppet/parser/functions.rb +6 -0
- data/lib/puppet/parser/functions/assert_type.rb +1 -1
- data/lib/puppet/parser/functions/binary_file.rb +24 -0
- data/lib/puppet/parser/functions/break.rb +39 -0
- data/lib/puppet/parser/functions/contain.rb +7 -15
- data/lib/puppet/parser/functions/defined.rb +2 -2
- data/lib/puppet/parser/functions/dig.rb +1 -1
- data/lib/puppet/parser/functions/each.rb +1 -1
- data/lib/puppet/parser/functions/epp.rb +2 -2
- data/lib/puppet/parser/functions/filter.rb +1 -1
- data/lib/puppet/parser/functions/find_file.rb +28 -0
- data/lib/puppet/parser/functions/hiera.rb +4 -4
- data/lib/puppet/parser/functions/hiera_array.rb +1 -1
- data/lib/puppet/parser/functions/hiera_hash.rb +1 -1
- data/lib/puppet/parser/functions/hiera_include.rb +1 -1
- data/lib/puppet/parser/functions/include.rb +4 -8
- data/lib/puppet/parser/functions/inline_epp.rb +1 -1
- data/lib/puppet/parser/functions/lest.rb +1 -1
- data/lib/puppet/parser/functions/lookup.rb +4 -2
- data/lib/puppet/parser/functions/map.rb +1 -1
- data/lib/puppet/parser/functions/match.rb +1 -1
- data/lib/puppet/parser/functions/new.rb +414 -18
- data/lib/puppet/parser/functions/next.rb +38 -0
- data/lib/puppet/parser/functions/reduce.rb +1 -1
- data/lib/puppet/parser/functions/regsubst.rb +4 -2
- data/lib/puppet/parser/functions/require.rb +4 -27
- data/lib/puppet/parser/functions/return.rb +71 -0
- data/lib/puppet/parser/functions/reverse_each.rb +1 -1
- data/lib/puppet/parser/functions/scanf.rb +13 -8
- data/lib/puppet/parser/functions/slice.rb +1 -1
- data/lib/puppet/parser/functions/split.rb +1 -1
- data/lib/puppet/parser/functions/step.rb +1 -1
- data/lib/puppet/parser/functions/strftime.rb +185 -0
- data/lib/puppet/parser/functions/then.rb +1 -1
- data/lib/puppet/parser/functions/type.rb +1 -1
- data/lib/puppet/parser/functions/with.rb +3 -3
- data/lib/puppet/parser/resource.rb +8 -5
- data/lib/puppet/parser/scope.rb +1 -1
- data/lib/puppet/plugins/configuration.rb +8 -0
- data/lib/puppet/plugins/data_providers.rb +1 -0
- data/lib/puppet/plugins/data_providers/data_provider.rb +7 -28
- data/lib/puppet/plugins/data_providers/registry.rb +1 -0
- data/lib/puppet/pops.rb +4 -0
- data/lib/puppet/pops/evaluator/access_operator.rb +36 -5
- data/lib/puppet/pops/evaluator/closure.rb +81 -12
- data/lib/puppet/pops/evaluator/compare_operator.rb +24 -1
- data/lib/puppet/pops/evaluator/evaluator_impl.rb +29 -5
- data/lib/puppet/pops/evaluator/json_strict_literal_evaluator.rb +1 -1
- data/lib/puppet/pops/evaluator/runtime3_converter.rb +53 -62
- data/lib/puppet/pops/evaluator/runtime3_support.rb +15 -6
- data/lib/puppet/pops/functions/dispatch.rb +9 -2
- data/lib/puppet/pops/functions/dispatcher.rb +3 -1
- data/lib/puppet/pops/functions/function.rb +19 -2
- data/lib/puppet/pops/issues.rb +9 -0
- data/lib/puppet/pops/label_provider.rb +2 -2
- data/lib/puppet/pops/loader/loader.rb +17 -0
- data/lib/puppet/pops/loader/static_loader.rb +0 -41
- data/lib/puppet/pops/lookup.rb +12 -0
- data/lib/puppet/pops/lookup/context.rb +86 -0
- data/lib/puppet/pops/lookup/explainer.rb +46 -6
- data/lib/puppet/pops/lookup/invocation.rb +19 -0
- data/lib/puppet/pops/lookup/sub_lookup.rb +1 -1
- data/lib/puppet/pops/model/factory.rb +20 -8
- data/lib/puppet/pops/model/model_label_provider.rb +3 -0
- data/lib/puppet/pops/model/model_meta.rb +2 -0
- data/lib/puppet/pops/model/model_tree_dumper.rb +14 -0
- data/lib/puppet/pops/parser/egrammar.ra +11 -6
- data/lib/puppet/pops/parser/eparser.rb +1112 -1086
- data/lib/puppet/pops/parser/heredoc_support.rb +1 -2
- data/lib/puppet/pops/pcore.rb +1 -0
- data/lib/puppet/pops/puppet_stack.rb +3 -3
- data/lib/puppet/pops/resource/param.rb +5 -1
- data/lib/puppet/pops/resource/resource_type_impl.rb +8 -4
- data/lib/puppet/pops/resource/resource_type_set.pcore +1 -0
- data/lib/puppet/pops/serialization/abstract_reader.rb +19 -2
- data/lib/puppet/pops/serialization/abstract_writer.rb +16 -3
- data/lib/puppet/pops/serialization/deserializer.rb +5 -1
- data/lib/puppet/pops/serialization/extension.rb +2 -0
- data/lib/puppet/pops/serialization/json.rb +76 -26
- data/lib/puppet/pops/serialization/serializer.rb +5 -1
- data/lib/puppet/pops/serialization/time_factory.rb +2 -1
- data/lib/puppet/pops/time/timespan.rb +718 -0
- data/lib/puppet/pops/time/timestamp.rb +148 -0
- data/lib/puppet/pops/types/p_binary_type.rb +220 -0
- data/lib/puppet/pops/types/p_object_type.rb +12 -6
- data/lib/puppet/pops/types/p_sensitive_type.rb +5 -1
- data/lib/puppet/pops/types/p_timespan_type.rb +141 -0
- data/lib/puppet/pops/types/p_timestamp_type.rb +69 -0
- data/lib/puppet/pops/types/string_converter.rb +62 -0
- data/lib/puppet/pops/types/type_asserter.rb +1 -1
- data/lib/puppet/pops/types/type_calculator.rb +17 -3
- data/lib/puppet/pops/types/type_factory.rb +35 -1
- data/lib/puppet/pops/types/type_formatter.rb +64 -11
- data/lib/puppet/pops/types/type_mismatch_describer.rb +110 -61
- data/lib/puppet/pops/types/type_parser.rb +18 -4
- data/lib/puppet/pops/types/types.rb +98 -63
- data/lib/puppet/pops/validation.rb +9 -1
- data/lib/puppet/pops/validation/checker4_0.rb +7 -0
- data/lib/puppet/property.rb +1 -1
- data/lib/puppet/provider.rb +3 -6
- data/lib/puppet/provider/mcx/mcxcontent.rb +1 -1
- data/lib/puppet/provider/mount/parsed.rb +18 -4
- data/lib/puppet/provider/nameservice/directoryservice.rb +15 -7
- data/lib/puppet/provider/package/gem.rb +6 -1
- data/lib/puppet/provider/package/pip.rb +0 -1
- data/lib/puppet/provider/package/pkg.rb +5 -1
- data/lib/puppet/provider/package/pkgng.rb +1 -1
- data/lib/puppet/provider/package/yum.rb +10 -0
- data/lib/puppet/provider/service/launchd.rb +1 -0
- data/lib/puppet/provider/user/directoryservice.rb +6 -6
- data/lib/puppet/provider/yumrepo/inifile.rb +1 -1
- data/lib/puppet/provider/zpool/zpool.rb +1 -1
- data/lib/puppet/resource.rb +54 -12
- data/lib/puppet/resource/capability_finder.rb +15 -9
- data/lib/puppet/resource/catalog.rb +25 -6
- data/lib/puppet/resource/type.rb +3 -1
- data/lib/puppet/settings.rb +1 -1
- data/lib/puppet/settings/environment_conf.rb +12 -4
- data/lib/puppet/syntax_checkers/base64.rb +41 -0
- data/lib/puppet/syntax_checkers/json.rb +0 -2
- data/lib/puppet/transaction.rb +6 -0
- data/lib/puppet/transaction/additional_resource_generator.rb +5 -0
- data/lib/puppet/transaction/report.rb +7 -2
- data/lib/puppet/type.rb +2 -1
- data/lib/puppet/type/file/checksum.rb +1 -0
- data/lib/puppet/type/file/content.rb +4 -4
- data/lib/puppet/type/mount.rb +44 -0
- data/lib/puppet/type/ssh_authorized_key.rb +1 -1
- data/lib/puppet/type/tidy.rb +3 -0
- data/lib/puppet/type/user.rb +12 -6
- data/lib/puppet/util/log.rb +25 -0
- data/lib/puppet/util/plist.rb +8 -3
- data/lib/puppet/version.rb +1 -1
- data/lib/puppet_x.rb +7 -1
- data/spec/integration/application/apply_spec.rb +118 -0
- data/spec/integration/parser/compiler_spec.rb +28 -0
- data/spec/integration/parser/pcore_resource_spec.rb +40 -3
- data/spec/integration/provider/mount_spec.rb +2 -1
- data/spec/integration/util/windows/principal_spec.rb +2 -2
- data/spec/integration/util/windows/registry_spec.rb +4 -4
- data/spec/lib/puppet_spec/compiler.rb +5 -1
- data/spec/lib/puppet_spec/unindent.rb +5 -0
- data/spec/shared_contexts/types_setup.rb +6 -0
- data/spec/shared_examples/rhel_package_provider.rb +16 -0
- data/spec/spec_helper.rb +1 -0
- data/spec/unit/agent_spec.rb +11 -0
- data/spec/unit/application/lookup_spec.rb +94 -3
- data/spec/unit/capability_spec.rb +22 -0
- data/spec/unit/configurer_spec.rb +8 -0
- data/spec/unit/face/epp_face_spec.rb +22 -3
- data/spec/unit/functions/assert_type_spec.rb +3 -3
- data/spec/unit/functions/binary_file_spec.rb +46 -0
- data/spec/unit/functions/break_spec.rb +89 -0
- data/spec/unit/{parser/functions → functions}/contain_spec.rb +68 -3
- data/spec/unit/functions/find_file_spec.rb +69 -0
- data/spec/unit/functions/include_spec.rb +175 -0
- data/spec/unit/functions/logging_spec.rb +54 -0
- data/spec/unit/functions/lookup_spec.rb +3 -3
- data/spec/unit/functions/new_spec.rb +105 -5
- data/spec/unit/functions/next_spec.rb +93 -0
- data/spec/unit/functions/require_spec.rb +83 -0
- data/spec/unit/functions/return_spec.rb +105 -0
- data/spec/unit/{parser/functions → functions}/shared.rb +14 -11
- data/spec/unit/functions/strftime_spec.rb +152 -0
- data/spec/unit/functions4_spec.rb +22 -0
- data/spec/unit/indirector/face_spec.rb +10 -2
- data/spec/unit/network/http/error_spec.rb +1 -2
- data/spec/unit/network/http/handler_spec.rb +6 -5
- data/spec/unit/parser/functions/hiera_array_spec.rb +1 -1
- data/spec/unit/parser/functions/hiera_hash_spec.rb +1 -1
- data/spec/unit/parser/functions/hiera_include_spec.rb +1 -1
- data/spec/unit/parser/functions/hiera_spec.rb +1 -1
- data/spec/unit/parser/functions/lookup_spec.rb +1 -1
- data/spec/unit/parser/functions/regsubst_spec.rb +1 -1
- data/spec/unit/parser/functions/split_spec.rb +1 -1
- data/spec/unit/pops/evaluator/access_ops_spec.rb +81 -1
- data/spec/unit/pops/evaluator/arithmetic_ops_spec.rb +170 -0
- data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +29 -4
- data/spec/unit/pops/evaluator/runtime3_converter_spec.rb +112 -4
- data/spec/unit/pops/loaders/dependency_loader_spec.rb +12 -0
- data/spec/unit/pops/loaders/static_loader_spec.rb +0 -26
- data/spec/unit/pops/lookup/context_spec.rb +149 -0
- data/spec/unit/pops/parser/parse_functions_spec.rb +19 -0
- data/spec/unit/pops/parser/parse_lambda_spec.rb +19 -0
- data/spec/unit/pops/puppet_stack_spec.rb +1 -1
- data/spec/unit/pops/resource/resource_type_impl_spec.rb +74 -0
- data/spec/unit/pops/serialization/packer_spec.rb +34 -14
- data/spec/unit/pops/serialization/serialization_spec.rb +67 -5
- data/spec/unit/pops/time/timespan_spec.rb +121 -0
- data/spec/unit/pops/types/p_binary_type_spec.rb +243 -0
- data/spec/unit/pops/types/p_object_type_spec.rb +7 -7
- data/spec/unit/pops/types/p_sensitive_type_spec.rb +1 -1
- data/spec/unit/pops/types/p_timespan_type_spec.rb +273 -0
- data/spec/unit/pops/types/p_timestamp_type_spec.rb +311 -0
- data/spec/unit/pops/types/p_type_set_type_spec.rb +13 -13
- data/spec/unit/pops/types/ruby_generator_spec.rb +12 -12
- data/spec/unit/pops/types/string_converter_spec.rb +89 -0
- data/spec/unit/pops/types/type_asserter_spec.rb +3 -3
- data/spec/unit/pops/types/type_calculator_spec.rb +113 -5
- data/spec/unit/pops/types/type_formatter_spec.rb +40 -0
- data/spec/unit/pops/types/type_mismatch_describer_spec.rb +49 -38
- data/spec/unit/pops/types/type_parser_spec.rb +87 -4
- data/spec/unit/pops/types/types_spec.rb +1 -1
- data/spec/unit/pops/validator/validator_spec.rb +23 -0
- data/spec/unit/provider/mount/parsed_spec.rb +47 -29
- data/spec/unit/provider/package/pkg_spec.rb +109 -99
- data/spec/unit/provider/ssh_authorized_key/parsed_spec.rb +1 -0
- data/spec/unit/provider/user/aix_spec.rb +1 -1
- data/spec/unit/provider/user/directoryservice_spec.rb +101 -30
- data/spec/unit/resource/capability_finder_spec.rb +29 -7
- data/spec/unit/resource/catalog_spec.rb +127 -0
- data/spec/unit/ssl/certificate_request_spec.rb +1 -1
- data/spec/unit/transaction/additional_resource_generator_spec.rb +30 -0
- data/spec/unit/transaction/persistence_spec.rb +1 -6
- data/spec/unit/transaction/report_spec.rb +23 -0
- data/spec/unit/transaction_spec.rb +38 -0
- data/spec/unit/type/mount_spec.rb +5 -0
- data/spec/unit/util/plist_spec.rb +14 -2
- metadata +71 -12
- data/spec/integration/parser/functions/require_spec.rb +0 -43
- data/spec/unit/parser/functions/include_spec.rb +0 -55
- data/spec/unit/parser/functions/require_spec.rb +0 -68
@@ -1,43 +0,0 @@
|
|
1
|
-
#! /usr/bin/env ruby
|
2
|
-
require 'spec_helper'
|
3
|
-
|
4
|
-
describe "The require function" do
|
5
|
-
before :each do
|
6
|
-
@node = Puppet::Node.new("mynode")
|
7
|
-
@compiler = Puppet::Parser::Compiler.new(@node)
|
8
|
-
|
9
|
-
@compiler.send(:evaluate_main)
|
10
|
-
@compiler.catalog.client_version = "0.25"
|
11
|
-
@scope = @compiler.topscope
|
12
|
-
# preload our functions
|
13
|
-
Puppet::Parser::Functions.function(:include)
|
14
|
-
Puppet::Parser::Functions.function(:require)
|
15
|
-
end
|
16
|
-
|
17
|
-
it "should add a dependency between the 'required' class and our class" do
|
18
|
-
@compiler.environment.known_resource_types.add Puppet::Resource::Type.new(:hostclass, "requiredclass")
|
19
|
-
|
20
|
-
@scope.function_require(["requiredclass"])
|
21
|
-
expect(@scope.resource["require"]).not_to be_nil
|
22
|
-
ref = @scope.resource["require"].shift
|
23
|
-
expect(ref.type).to eq("Class")
|
24
|
-
expect(ref.title).to eq("Requiredclass")
|
25
|
-
end
|
26
|
-
|
27
|
-
it "should queue relationships between the 'required' class and our classes" do
|
28
|
-
@compiler.environment.known_resource_types.add Puppet::Resource::Type.new(:hostclass, "requiredclass1")
|
29
|
-
@compiler.environment.known_resource_types.add Puppet::Resource::Type.new(:hostclass, "requiredclass2")
|
30
|
-
|
31
|
-
@scope.function_require(["requiredclass1"])
|
32
|
-
@scope.function_require(["requiredclass2"])
|
33
|
-
|
34
|
-
expect(@scope.resource["require"]).not_to be_nil
|
35
|
-
|
36
|
-
(ref1,ref2) = @scope.resource["require"]
|
37
|
-
expect(ref1.type).to eq("Class")
|
38
|
-
expect(ref1.title).to eq("Requiredclass1")
|
39
|
-
expect(ref2.type).to eq("Class")
|
40
|
-
expect(ref2.title).to eq("Requiredclass2")
|
41
|
-
end
|
42
|
-
|
43
|
-
end
|
@@ -1,55 +0,0 @@
|
|
1
|
-
#! /usr/bin/env ruby
|
2
|
-
require 'spec_helper'
|
3
|
-
require 'unit/parser/functions/shared'
|
4
|
-
require 'puppet_spec/compiler'
|
5
|
-
|
6
|
-
describe "the 'include' function" do
|
7
|
-
include PuppetSpec::Compiler
|
8
|
-
|
9
|
-
before :each do
|
10
|
-
@compiler = Puppet::Parser::Compiler.new(Puppet::Node.new("foo"))
|
11
|
-
@scope = Puppet::Parser::Scope.new(@compiler)
|
12
|
-
end
|
13
|
-
|
14
|
-
it "should exist" do
|
15
|
-
expect(Puppet::Parser::Functions.function("include")).to eq("function_include")
|
16
|
-
end
|
17
|
-
|
18
|
-
it "should include a single class" do
|
19
|
-
inc = "::foo"
|
20
|
-
@compiler.expects(:evaluate_classes).with {|klasses,parser,lazy| klasses == [inc]}.returns([inc])
|
21
|
-
@scope.function_include(["foo"])
|
22
|
-
end
|
23
|
-
|
24
|
-
it "should include multiple classes" do
|
25
|
-
inc = ["::foo","::bar"]
|
26
|
-
@compiler.expects(:evaluate_classes).with {|klasses,parser,lazy| klasses == inc}.returns(inc)
|
27
|
-
@scope.function_include(["foo","bar"])
|
28
|
-
end
|
29
|
-
|
30
|
-
it "should include multiple classes passed in an array" do
|
31
|
-
inc = ["::foo","::bar"]
|
32
|
-
@compiler.expects(:evaluate_classes).with {|klasses,parser,lazy| klasses == inc}.returns(inc)
|
33
|
-
@scope.function_include([["foo","bar"]])
|
34
|
-
end
|
35
|
-
|
36
|
-
it "should flatten nested arrays" do
|
37
|
-
inc = ["::foo","::bar","::baz"]
|
38
|
-
@compiler.expects(:evaluate_classes).with {|klasses,parser,lazy| klasses == inc}.returns(inc)
|
39
|
-
@scope.function_include([["foo","bar"],"baz"])
|
40
|
-
end
|
41
|
-
|
42
|
-
it "should not lazily evaluate the included class" do
|
43
|
-
@compiler.expects(:evaluate_classes).with {|klasses,parser,lazy| lazy == false}.returns("foo")
|
44
|
-
@scope.function_include(["foo"])
|
45
|
-
end
|
46
|
-
|
47
|
-
it "should raise if the class is not found" do
|
48
|
-
@scope.stubs(:source).returns(true)
|
49
|
-
expect { @scope.function_include(["nosuchclass"]) }.to raise_error(Puppet::Error)
|
50
|
-
end
|
51
|
-
|
52
|
-
it_should_behave_like 'all functions transforming relative to absolute names', :function_include
|
53
|
-
it_should_behave_like 'an inclusion function, regardless of the type of class reference,', :include
|
54
|
-
|
55
|
-
end
|
@@ -1,68 +0,0 @@
|
|
1
|
-
#! /usr/bin/env ruby
|
2
|
-
require 'spec_helper'
|
3
|
-
require 'unit/parser/functions/shared'
|
4
|
-
require 'puppet_spec/compiler'
|
5
|
-
|
6
|
-
describe "the require function" do
|
7
|
-
include PuppetSpec::Compiler
|
8
|
-
# before :all do
|
9
|
-
# Puppet::Parser::Functions.autoloader.loadall
|
10
|
-
# end
|
11
|
-
|
12
|
-
before :each do
|
13
|
-
@catalog = stub 'catalog'
|
14
|
-
|
15
|
-
node = Puppet::Node.new('localhost')
|
16
|
-
compiler = Puppet::Parser::Compiler.new(node)
|
17
|
-
@scope = Puppet::Parser::Scope.new(compiler)
|
18
|
-
|
19
|
-
@scope.stubs(:findresource)
|
20
|
-
@klass = stub 'class', :name => "myclass"
|
21
|
-
@scope.environment.known_resource_types.stubs(:find_hostclass).returns(@klass)
|
22
|
-
|
23
|
-
@resource = Puppet::Parser::Resource.new(:file, "/my/file", :scope => @scope, :source => "source")
|
24
|
-
@scope.stubs(:resource).returns @resource
|
25
|
-
end
|
26
|
-
|
27
|
-
it "should exist" do
|
28
|
-
expect(Puppet::Parser::Functions.function("require")).to eq("function_require")
|
29
|
-
end
|
30
|
-
|
31
|
-
it "should delegate to the 'include' puppet function" do
|
32
|
-
@scope.compiler.expects(:evaluate_classes).with(["::myclass"], @scope, false)
|
33
|
-
|
34
|
-
@scope.function_require(["myclass"])
|
35
|
-
end
|
36
|
-
|
37
|
-
it "should set the 'require' parameter on the resource to a resource reference" do
|
38
|
-
@scope.compiler.stubs(:evaluate_classes)
|
39
|
-
@scope.function_require(["myclass"])
|
40
|
-
|
41
|
-
expect(@resource["require"]).to be_instance_of(Array)
|
42
|
-
expect(@resource["require"][0]).to be_instance_of(Puppet::Resource)
|
43
|
-
end
|
44
|
-
|
45
|
-
it "should lookup the absolute class path" do
|
46
|
-
@scope.compiler.stubs(:evaluate_classes)
|
47
|
-
|
48
|
-
@scope.environment.known_resource_types.expects(:find_hostclass).with("::myclass").returns(@klass)
|
49
|
-
@klass.expects(:name).returns("myclass")
|
50
|
-
|
51
|
-
@scope.function_require(["myclass"])
|
52
|
-
end
|
53
|
-
|
54
|
-
it "should append the required class to the require parameter" do
|
55
|
-
@scope.compiler.stubs(:evaluate_classes)
|
56
|
-
|
57
|
-
one = Puppet::Resource.new(:file, "/one")
|
58
|
-
@resource[:require] = one
|
59
|
-
@scope.function_require(["myclass"])
|
60
|
-
|
61
|
-
expect(@resource[:require]).to be_include(one)
|
62
|
-
expect(@resource[:require].detect { |r| r.to_s == "Class[Myclass]" }).to be_instance_of(Puppet::Resource)
|
63
|
-
end
|
64
|
-
|
65
|
-
it_should_behave_like 'all functions transforming relative to absolute names', :function_require
|
66
|
-
it_should_behave_like 'an inclusion function, regardless of the type of class reference,', :require
|
67
|
-
|
68
|
-
end
|