puppet 4.9.1-x86-mingw32 → 4.9.2-x86-mingw32
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 +1 -0
- data/lib/puppet/forge/repository.rb +1 -1
- data/lib/puppet/functions/assert_type.rb +3 -5
- data/lib/puppet/functions/yaml_data.rb +6 -1
- data/lib/puppet/pops/adapters.rb +10 -11
- data/lib/puppet/pops/evaluator/evaluator_impl.rb +2 -2
- data/lib/puppet/pops/evaluator/relationship_operator.rb +1 -1
- data/lib/puppet/pops/evaluator/runtime3_support.rb +1 -1
- data/lib/puppet/pops/loader/loader_paths.rb +4 -1
- data/lib/puppet/pops/loaders.rb +2 -0
- data/lib/puppet/pops/lookup/environment_data_provider.rb +10 -2
- data/lib/puppet/pops/lookup/hiera_config.rb +40 -8
- data/lib/puppet/pops/lookup/interpolation.rb +4 -2
- data/lib/puppet/pops/lookup/invocation.rb +2 -2
- data/lib/puppet/pops/lookup/lookup_adapter.rb +8 -2
- data/lib/puppet/pops/lookup/lookup_key_function_provider.rb +7 -3
- data/lib/puppet/pops/merge_strategy.rb +1 -1
- data/lib/puppet/pops/types/type_parser.rb +5 -11
- data/lib/puppet/ssl/certificate.rb +1 -1
- data/lib/puppet/ssl/certificate_request.rb +1 -1
- data/lib/puppet/version.rb +1 -1
- data/spec/lib/puppet_spec/language.rb +3 -1
- data/spec/unit/face/module/search_spec.rb +1 -1
- data/spec/unit/forge/repository_spec.rb +27 -0
- data/spec/unit/functions/lookup_spec.rb +396 -43
- data/spec/unit/network/http/factory_spec.rb +4 -0
- data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +5 -0
- data/spec/unit/pops/evaluator/evaluator_rspec_helper.rb +28 -24
- data/spec/unit/pops/loaders/loaders_spec.rb +117 -22
- data/spec/unit/pops/types/ruby_generator_spec.rb +13 -13
- data/spec/unit/pops/types/type_calculator_spec.rb +13 -25
- data/spec/unit/pops/types/type_parser_spec.rb +1 -4
- data/spec/unit/resource/type_spec.rb +8 -2
- data/spec/unit/ssl/certificate_factory_spec.rb +2 -2
- data/spec/unit/ssl/certificate_request_spec.rb +2 -3
- data/spec/unit/util/http_proxy_spec.rb +4 -0
- metadata +2 -2
@@ -4,6 +4,10 @@ require 'puppet/network/http'
|
|
4
4
|
require 'puppet/util/http_proxy'
|
5
5
|
|
6
6
|
describe Puppet::Network::HTTP::Factory do
|
7
|
+
before(:all) do
|
8
|
+
ENV['http_proxy'] = nil
|
9
|
+
ENV['HTTP_PROXY'] = nil
|
10
|
+
end
|
7
11
|
before :each do
|
8
12
|
Puppet::SSL::Key.indirection.terminus_class = :memory
|
9
13
|
Puppet::SSL::CertificateRequest.indirection.terminus_class = :memory
|
@@ -29,6 +29,11 @@ describe 'Puppet::Pops::Evaluator::EvaluatorImpl' do
|
|
29
29
|
@scope = Puppet::Parser::Scope.new(@compiler)
|
30
30
|
@scope.source = Puppet::Resource::Type.new(:node, 'node.example.com')
|
31
31
|
@scope.parent = @compiler.topscope
|
32
|
+
Puppet.push_context(:loaders => @compiler.loaders)
|
33
|
+
end
|
34
|
+
|
35
|
+
after(:each) do
|
36
|
+
Puppet.pop_context
|
32
37
|
end
|
33
38
|
|
34
39
|
let(:environment) { Puppet::Node::Environment.create(:testing, []) }
|
@@ -23,18 +23,20 @@ module EvaluatorRspecHelper
|
|
23
23
|
# top_scope = Puppet::Parser::Scope.new(compiler)
|
24
24
|
|
25
25
|
evaluator = Puppet::Pops::Evaluator::EvaluatorImpl.new
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
26
|
+
Puppet.override(:loaders => compiler.loaders) do
|
27
|
+
result = evaluator.evaluate(in_top_scope.current, top_scope)
|
28
|
+
if in_named_scope
|
29
|
+
other_scope = Puppet::Parser::Scope.new(compiler, :namespace => scopename)
|
30
|
+
result = evaluator.evaluate(in_named_scope.current, other_scope)
|
31
|
+
end
|
32
|
+
if in_top_scope_again
|
33
|
+
result = evaluator.evaluate(in_top_scope_again.current, top_scope)
|
34
|
+
end
|
35
|
+
if block_given?
|
36
|
+
block.call(top_scope)
|
37
|
+
end
|
38
|
+
result
|
36
39
|
end
|
37
|
-
result
|
38
40
|
end
|
39
41
|
|
40
42
|
# Evaluate a Factory wrapper round a model object in top scope + local scope
|
@@ -52,20 +54,22 @@ module EvaluatorRspecHelper
|
|
52
54
|
top_scope = compiler.topscope()
|
53
55
|
|
54
56
|
evaluator = Puppet::Pops::Evaluator::EvaluatorImpl.new
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
top_scope.
|
60
|
-
|
57
|
+
Puppet.override(:loaders => compiler.loaders) do
|
58
|
+
result = evaluator.evaluate(in_top_scope.current, top_scope)
|
59
|
+
if in_local_scope
|
60
|
+
# This is really bad in 3.x scope
|
61
|
+
top_scope.with_guarded_scope do
|
62
|
+
top_scope.new_ephemeral(true)
|
63
|
+
result = evaluator.evaluate(in_local_scope.current, top_scope)
|
64
|
+
end
|
61
65
|
end
|
66
|
+
if in_top_scope_again
|
67
|
+
result = evaluator.evaluate(in_top_scope_again.current, top_scope)
|
68
|
+
end
|
69
|
+
if block_given?
|
70
|
+
block.call(top_scope)
|
71
|
+
end
|
72
|
+
result
|
62
73
|
end
|
63
|
-
if in_top_scope_again
|
64
|
-
result = evaluator.evaluate(in_top_scope_again.current, top_scope)
|
65
|
-
end
|
66
|
-
if block_given?
|
67
|
-
block.call(top_scope)
|
68
|
-
end
|
69
|
-
result
|
70
74
|
end
|
71
75
|
end
|
@@ -335,41 +335,136 @@ describe 'loaders' do
|
|
335
335
|
|
336
336
|
context 'when calling' do
|
337
337
|
let(:env) { environment_for(mix_4x_and_3x_functions) }
|
338
|
-
let(:
|
339
|
-
let(:
|
338
|
+
let(:compiler) { Puppet::Parser::Compiler.new(Puppet::Node.new("test", :environment => env)) }
|
339
|
+
let(:scope) { compiler.topscope }
|
340
|
+
let(:loader) { compiler.loaders.private_loader_for_module('user') }
|
340
341
|
|
341
|
-
|
342
|
-
Puppet.override(
|
343
|
-
|
344
|
-
expect(function.call(scope)).to eql("usee::callee() got 'first' - usee::callee() got 'second'")
|
342
|
+
around(:each) do |example|
|
343
|
+
Puppet.override(:current_environment => scope.environment, :global_scope => scope, :loaders => compiler.loaders) do
|
344
|
+
example.run
|
345
345
|
end
|
346
346
|
end
|
347
347
|
|
348
|
+
it 'a 3x function in dependent module can be called from a 4x function' do
|
349
|
+
function = loader.load_typed(typed_name(:function, 'user::caller')).value
|
350
|
+
expect(function.call(scope)).to eql("usee::callee() got 'first' - usee::callee() got 'second'")
|
351
|
+
end
|
352
|
+
|
348
353
|
it 'a 3x function in dependent module can be called from a puppet function' do
|
349
|
-
|
350
|
-
|
351
|
-
expect(function.call(scope)).to eql("usee::callee() got 'first' - usee::callee() got 'second'")
|
352
|
-
end
|
354
|
+
function = loader.load_typed(typed_name(:function, 'user::puppetcaller')).value
|
355
|
+
expect(function.call(scope)).to eql("usee::callee() got 'first' - usee::callee() got 'second'")
|
353
356
|
end
|
354
357
|
|
355
358
|
it 'a 4x function can be called from a puppet function' do
|
356
|
-
|
357
|
-
|
358
|
-
expect(function.call(scope)).to eql("usee::callee() got 'first' - usee::callee() got 'second'")
|
359
|
-
end
|
359
|
+
function = loader.load_typed(typed_name(:function, 'user::puppetcaller4')).value
|
360
|
+
expect(function.call(scope)).to eql("usee::callee() got 'first' - usee::callee() got 'second'")
|
360
361
|
end
|
362
|
+
|
361
363
|
it 'a puppet function can be called from a 4x function' do
|
362
|
-
|
363
|
-
|
364
|
-
expect(function.call(scope)).to eql("Did you call to say you love me?")
|
365
|
-
end
|
364
|
+
function = loader.load_typed(typed_name(:function, 'user::callingpuppet')).value
|
365
|
+
expect(function.call(scope)).to eql("Did you call to say you love me?")
|
366
366
|
end
|
367
367
|
|
368
368
|
it 'a 3x function can be called with caller scope propagated from a 4x function' do
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
369
|
+
function = loader.load_typed(typed_name(:function, 'user::caller_ws')).value
|
370
|
+
expect(function.call(scope, 'passed in scope')).to eql("usee::callee_ws() got 'passed in scope'")
|
371
|
+
end
|
372
|
+
end
|
373
|
+
|
374
|
+
context 'loading types' do
|
375
|
+
let(:env_name) { 'testenv' }
|
376
|
+
let(:environments_dir) { Puppet[:environmentpath] }
|
377
|
+
let(:env_dir) { File.join(environments_dir, env_name) }
|
378
|
+
let(:env) { Puppet::Node::Environment.create(env_name.to_sym, [File.join(populated_env_dir, 'modules')]) }
|
379
|
+
let(:metadata_json) {
|
380
|
+
<<-JSON
|
381
|
+
{
|
382
|
+
"name": "example/%1$s",
|
383
|
+
"version": "0.0.2",
|
384
|
+
"source": "git@github.com/example/example-%1$s.git",
|
385
|
+
"dependencies": [],
|
386
|
+
"author": "Bob the Builder",
|
387
|
+
"license": "Apache-2.0"%2$s
|
388
|
+
}
|
389
|
+
JSON
|
390
|
+
}
|
391
|
+
|
392
|
+
let(:env_dir_files) do
|
393
|
+
{
|
394
|
+
'modules' => {
|
395
|
+
'a' => {
|
396
|
+
'manifests' => {
|
397
|
+
'init.pp' => 'class a { notice(A::A) }'
|
398
|
+
},
|
399
|
+
'types' => {
|
400
|
+
'a.pp' => 'type A::A = Variant[B::B, String]',
|
401
|
+
'n.pp' => 'type A::N = C::C'
|
402
|
+
},
|
403
|
+
'metadata.json' => sprintf(metadata_json, 'a', ', "dependencies": [{ "name": "example/b" }]')
|
404
|
+
},
|
405
|
+
'b' => {
|
406
|
+
'types' => {
|
407
|
+
'b.pp' => 'type B::B = Variant[C::C, Float]',
|
408
|
+
'x.pp' => 'type B::X = A::A'
|
409
|
+
},
|
410
|
+
'metadata.json' => sprintf(metadata_json, 'b', ', "dependencies": [{ "name": "example/c" }]')
|
411
|
+
},
|
412
|
+
'c' => {
|
413
|
+
'types' => {
|
414
|
+
'c.pp' => 'type C::C = Integer'
|
415
|
+
},
|
416
|
+
'metadata.json' => sprintf(metadata_json, 'c', '')
|
417
|
+
},
|
418
|
+
}
|
419
|
+
}
|
420
|
+
end
|
421
|
+
|
422
|
+
let(:populated_env_dir) do
|
423
|
+
dir_contained_in(environments_dir, env_name => env_dir_files)
|
424
|
+
PuppetSpec::Files.record_tmp(env_dir)
|
425
|
+
env_dir
|
426
|
+
end
|
427
|
+
|
428
|
+
before(:each) do
|
429
|
+
Puppet.push_context(:loaders => Puppet::Pops::Loaders.new(env))
|
430
|
+
end
|
431
|
+
|
432
|
+
after(:each) do
|
433
|
+
Puppet.pop_context
|
434
|
+
end
|
435
|
+
|
436
|
+
it 'resolves types using the loader that loaded the type a -> b -> c' do
|
437
|
+
type = Puppet::Pops::Types::TypeParser.singleton.parse('A::A', Puppet::Pops::Loaders.find_loader('a'))
|
438
|
+
expect(type).to be_a(Puppet::Pops::Types::PTypeAliasType)
|
439
|
+
expect(type.name).to eql('A::A')
|
440
|
+
type = type.resolved_type
|
441
|
+
expect(type).to be_a(Puppet::Pops::Types::PVariantType)
|
442
|
+
type = type.types[0]
|
443
|
+
expect(type.name).to eql('B::B')
|
444
|
+
type = type.resolved_type
|
445
|
+
expect(type).to be_a(Puppet::Pops::Types::PVariantType)
|
446
|
+
type = type.types[0]
|
447
|
+
expect(type.name).to eql('C::C')
|
448
|
+
type = type.resolved_type
|
449
|
+
expect(type).to be_a(Puppet::Pops::Types::PIntegerType)
|
450
|
+
end
|
451
|
+
|
452
|
+
it 'will not resolve implicit transitive dependencies, a -> c' do
|
453
|
+
type = Puppet::Pops::Types::TypeParser.singleton.parse('A::N', Puppet::Pops::Loaders.find_loader('a'))
|
454
|
+
expect(type).to be_a(Puppet::Pops::Types::PTypeAliasType)
|
455
|
+
expect(type.name).to eql('A::N')
|
456
|
+
type = type.resolved_type
|
457
|
+
expect(type).to be_a(Puppet::Pops::Types::PTypeReferenceType)
|
458
|
+
expect(type.type_string).to eql('C::C')
|
459
|
+
end
|
460
|
+
|
461
|
+
it 'will not resolve reverse dependencies, b -> a' do
|
462
|
+
type = Puppet::Pops::Types::TypeParser.singleton.parse('B::X', Puppet::Pops::Loaders.find_loader('b'))
|
463
|
+
expect(type).to be_a(Puppet::Pops::Types::PTypeAliasType)
|
464
|
+
expect(type.name).to eql('B::X')
|
465
|
+
type = type.resolved_type
|
466
|
+
expect(type).to be_a(Puppet::Pops::Types::PTypeReferenceType)
|
467
|
+
expect(type.type_string).to eql('A::A')
|
373
468
|
end
|
374
469
|
end
|
375
470
|
|
@@ -40,16 +40,16 @@ describe 'Puppet Ruby Generator' do
|
|
40
40
|
|
41
41
|
context 'when generating anonymous classes' do
|
42
42
|
|
43
|
-
|
43
|
+
loader = nil
|
44
44
|
|
45
|
-
let(:first_type) { parser.parse('MyModule::FirstGenerated',
|
46
|
-
let(:second_type) { parser.parse('MyModule::SecondGenerated',
|
45
|
+
let(:first_type) { parser.parse('MyModule::FirstGenerated', loader) }
|
46
|
+
let(:second_type) { parser.parse('MyModule::SecondGenerated', loader) }
|
47
47
|
let(:first) { generator.create_class(first_type) }
|
48
48
|
let(:second) { generator.create_class(second_type) }
|
49
49
|
|
50
50
|
before(:each) do
|
51
|
-
eval_and_collect_notices(source) do |topscope
|
52
|
-
|
51
|
+
eval_and_collect_notices(source) do |topscope|
|
52
|
+
loader = topscope.compiler.loaders.find_loader(nil)
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
@@ -149,9 +149,9 @@ describe 'Puppet Ruby Generator' do
|
|
149
149
|
if module_def.nil?
|
150
150
|
first_type = nil
|
151
151
|
second_type = nil
|
152
|
-
eval_and_collect_notices(source) do
|
153
|
-
first_type = parser.parse('MyModule::FirstGenerated'
|
154
|
-
second_type = parser.parse('MyModule::SecondGenerated'
|
152
|
+
eval_and_collect_notices(source) do
|
153
|
+
first_type = parser.parse('MyModule::FirstGenerated')
|
154
|
+
second_type = parser.parse('MyModule::SecondGenerated')
|
155
155
|
|
156
156
|
loader = Loaders.find_loader(nil)
|
157
157
|
Loaders.implementation_registry.register_type_mapping(
|
@@ -327,8 +327,8 @@ describe 'Puppet Ruby Generator' do
|
|
327
327
|
let(:fourth) { generator.create_class(fourth_type) }
|
328
328
|
|
329
329
|
before(:each) do
|
330
|
-
eval_and_collect_notices(source) do
|
331
|
-
typeset = parser.parse('OtherModule'
|
330
|
+
eval_and_collect_notices(source) do
|
331
|
+
typeset = parser.parse('OtherModule')
|
332
332
|
end
|
333
333
|
end
|
334
334
|
|
@@ -457,9 +457,9 @@ describe 'Puppet Ruby Generator' do
|
|
457
457
|
# environment specific settings are configured by the spec_helper in before(:each)
|
458
458
|
if module_def.nil?
|
459
459
|
typeset = nil
|
460
|
-
eval_and_collect_notices(source) do
|
461
|
-
typeset1 = parser.parse('MyModule'
|
462
|
-
typeset2 = parser.parse('OtherModule'
|
460
|
+
eval_and_collect_notices(source) do
|
461
|
+
typeset1 = parser.parse('MyModule')
|
462
|
+
typeset2 = parser.parse('OtherModule')
|
463
463
|
|
464
464
|
loader = Loaders.find_loader(nil)
|
465
465
|
Loaders.implementation_registry.register_type_mapping(
|
@@ -1480,7 +1480,7 @@ describe 'The type calculator' do
|
|
1480
1480
|
loader = Object.new
|
1481
1481
|
loader.expects(:load).with(:type, 'tree').returns t
|
1482
1482
|
|
1483
|
-
Adapters::LoaderAdapter.expects(:loader_for_model_object).
|
1483
|
+
Adapters::LoaderAdapter.expects(:loader_for_model_object).at_least_once.returns loader
|
1484
1484
|
|
1485
1485
|
t.resolve(parser, scope)
|
1486
1486
|
expect(calculator.assignable?(t, parser.parse('Hash[String,Variant[String,Hash[String,Variant[String,String]]]]'))).to be_truthy
|
@@ -1496,7 +1496,7 @@ describe 'The type calculator' do
|
|
1496
1496
|
loader.expects(:load).with(:type, 'tree1').returns t1
|
1497
1497
|
loader.expects(:load).with(:type, 'tree2').returns t2
|
1498
1498
|
|
1499
|
-
Adapters::LoaderAdapter.expects(:loader_for_model_object).
|
1499
|
+
Adapters::LoaderAdapter.expects(:loader_for_model_object).at_least_once.returns loader
|
1500
1500
|
|
1501
1501
|
t1.resolve(parser, scope)
|
1502
1502
|
t2.resolve(parser, scope)
|
@@ -1504,19 +1504,16 @@ describe 'The type calculator' do
|
|
1504
1504
|
end
|
1505
1505
|
|
1506
1506
|
it 'crossing recursive aliases are assignable' do
|
1507
|
-
scope = Object.new
|
1508
|
-
|
1509
1507
|
t1 = type_alias_t('Tree1', 'Hash[String,Variant[String,Tree2]]')
|
1510
1508
|
t2 = type_alias_t('Tree2', 'Hash[String,Variant[String,Tree1]]')
|
1511
1509
|
loader = Object.new
|
1512
1510
|
loader.expects(:load).with(:type, 'tree1').returns t1
|
1513
1511
|
loader.expects(:load).with(:type, 'tree2').returns t2
|
1514
|
-
loader.expects(:is_a?).with(Loader::Loader).returns true
|
1515
1512
|
|
1516
|
-
Adapters::LoaderAdapter.expects(:loader_for_model_object).
|
1513
|
+
Adapters::LoaderAdapter.expects(:loader_for_model_object).at_least_once.returns loader
|
1517
1514
|
|
1518
|
-
t1.resolve(parser,
|
1519
|
-
t2.resolve(parser,
|
1515
|
+
t1.resolve(parser, loader)
|
1516
|
+
t2.resolve(parser, loader)
|
1520
1517
|
expect(calculator.assignable?(t1, t2)).to be_truthy
|
1521
1518
|
end
|
1522
1519
|
|
@@ -1526,8 +1523,7 @@ describe 'The type calculator' do
|
|
1526
1523
|
ta = type_alias_t('PositiveInteger', 'Integer[0,default]')
|
1527
1524
|
loader = Object.new
|
1528
1525
|
loader.expects(:load).with(:type, 'positiveinteger').returns ta
|
1529
|
-
Adapters::LoaderAdapter.expects(:loader_for_model_object)
|
1530
|
-
.with(instance_of(Model::QualifiedReference), scope).returns loader
|
1526
|
+
Adapters::LoaderAdapter.expects(:loader_for_model_object).at_least_once.returns loader
|
1531
1527
|
|
1532
1528
|
t1 = type_t(range_t(0, :default))
|
1533
1529
|
t2 = parser.parse('Type[PositiveInteger]', scope)
|
@@ -1540,8 +1536,7 @@ describe 'The type calculator' do
|
|
1540
1536
|
ta = type_alias_t('PositiveIntegerType', 'Type[Integer[0,default]]')
|
1541
1537
|
loader = Object.new
|
1542
1538
|
loader.expects(:load).with(:type, 'positiveintegertype').returns ta
|
1543
|
-
Adapters::LoaderAdapter.expects(:loader_for_model_object)
|
1544
|
-
.with(instance_of(Model::QualifiedReference), scope).returns loader
|
1539
|
+
Adapters::LoaderAdapter.expects(:loader_for_model_object).at_least_once.returns loader
|
1545
1540
|
|
1546
1541
|
t1 = type_t(range_t(0, :default))
|
1547
1542
|
t2 = parser.parse('PositiveIntegerType', scope)
|
@@ -1554,8 +1549,7 @@ describe 'The type calculator' do
|
|
1554
1549
|
ta = type_alias_t('PositiveInteger', 'Integer[0,default]')
|
1555
1550
|
loader = Object.new
|
1556
1551
|
loader.expects(:load).with(:type, 'positiveinteger').returns ta
|
1557
|
-
Adapters::LoaderAdapter.expects(:loader_for_model_object)
|
1558
|
-
.with(instance_of(Model::QualifiedReference), scope).returns loader
|
1552
|
+
Adapters::LoaderAdapter.expects(:loader_for_model_object).at_least_once.returns loader
|
1559
1553
|
|
1560
1554
|
t1 = type_t(type_t(range_t(0, :default)))
|
1561
1555
|
t2 = parser.parse('Type[Type[PositiveInteger]]', scope)
|
@@ -1568,8 +1562,7 @@ describe 'The type calculator' do
|
|
1568
1562
|
ta = type_alias_t('PositiveIntegerType', 'Type[Integer[0,default]]')
|
1569
1563
|
loader = Object.new
|
1570
1564
|
loader.expects(:load).with(:type, 'positiveintegertype').returns ta
|
1571
|
-
Adapters::LoaderAdapter.expects(:loader_for_model_object)
|
1572
|
-
.with(instance_of(Model::QualifiedReference), scope).returns loader
|
1565
|
+
Adapters::LoaderAdapter.expects(:loader_for_model_object).at_least_once.returns loader
|
1573
1566
|
|
1574
1567
|
t1 = type_t(type_t(range_t(0, :default)))
|
1575
1568
|
t2 = parser.parse('Type[PositiveIntegerType]', scope)
|
@@ -1866,31 +1859,26 @@ describe 'The type calculator' do
|
|
1866
1859
|
end
|
1867
1860
|
|
1868
1861
|
it 'should consider x an instance of the aliased type that uses self recursion' do
|
1869
|
-
scope = Object.new
|
1870
|
-
|
1871
1862
|
t = type_alias_t('Tree', 'Hash[String,Variant[String,Tree]]')
|
1872
1863
|
loader = Object.new
|
1873
1864
|
loader.expects(:load).with(:type, 'tree').returns t
|
1874
1865
|
|
1875
|
-
Adapters::LoaderAdapter.expects(:loader_for_model_object).
|
1866
|
+
Adapters::LoaderAdapter.expects(:loader_for_model_object).at_least_once.returns loader
|
1876
1867
|
|
1877
|
-
t.resolve(parser,
|
1868
|
+
t.resolve(parser, loader)
|
1878
1869
|
expect(calculator.instance?(t, {'a'=>{'aa'=>{'aaa'=>'aaaa'}}, 'b'=>'bb'})).to be_truthy
|
1879
1870
|
end
|
1880
1871
|
|
1881
1872
|
it 'should consider x an instance of the aliased type that uses contains an alias that causes self recursion' do
|
1882
|
-
scope = Object.new
|
1883
|
-
|
1884
1873
|
t1 = type_alias_t('Tree', 'Hash[String,Variant[String,OtherTree]]')
|
1885
1874
|
t2 = type_alias_t('OtherTree', 'Hash[String,Tree]')
|
1886
1875
|
loader = Object.new
|
1887
1876
|
loader.expects(:load).with(:type, 'tree').returns t1
|
1888
1877
|
loader.expects(:load).with(:type, 'othertree').returns t2
|
1889
|
-
loader.expects(:is_a?).with(Loader::Loader).returns true
|
1890
1878
|
|
1891
|
-
Adapters::LoaderAdapter.expects(:loader_for_model_object).
|
1879
|
+
Adapters::LoaderAdapter.expects(:loader_for_model_object).at_least_once.returns loader
|
1892
1880
|
|
1893
|
-
t1.resolve(parser,
|
1881
|
+
t1.resolve(parser, loader)
|
1894
1882
|
expect(calculator.instance?(t1, {'a'=>{'aa'=>{'aaa'=>'aaaa'}}, 'b'=>'bb'})).to be_truthy
|
1895
1883
|
end
|
1896
1884
|
end
|
@@ -158,7 +158,7 @@ describe TypeParser do
|
|
158
158
|
let(:loader) { Object.new }
|
159
159
|
|
160
160
|
before :each do
|
161
|
-
Adapters::LoaderAdapter.expects(:loader_for_model_object).
|
161
|
+
Adapters::LoaderAdapter.expects(:loader_for_model_object).returns loader
|
162
162
|
end
|
163
163
|
|
164
164
|
it 'interprets anything that is not found by the loader to be a type reference' do
|
@@ -194,9 +194,6 @@ describe TypeParser do
|
|
194
194
|
|
195
195
|
context 'with loader context' do
|
196
196
|
let(:loader) { Puppet::Pops::Loader::BaseLoader.new(nil, "type_parser_unit_test_loader") }
|
197
|
-
before :each do
|
198
|
-
Puppet::Pops::Adapters::LoaderAdapter.expects(:loader_for_model_object).never
|
199
|
-
end
|
200
197
|
|
201
198
|
it 'interprets anything that is not found by the loader to be a type reference' do
|
202
199
|
loader.expects(:load).with(:type, 'nonesuch').returns nil
|
@@ -262,11 +262,17 @@ describe Puppet::Resource::Type do
|
|
262
262
|
wrap3x(Puppet::Pops::Model::Factory.NUMBER(number).var())
|
263
263
|
end
|
264
264
|
|
265
|
-
before do
|
266
|
-
|
265
|
+
before(:each) do
|
266
|
+
compiler = Puppet::Parser::Compiler.new(Puppet::Node.new("foo"))
|
267
|
+
@scope = Puppet::Parser::Scope.new(compiler, :source => stub("source"))
|
267
268
|
@resource = Puppet::Parser::Resource.new(:foo, "bar", :scope => @scope)
|
268
269
|
@type = Puppet::Resource::Type.new(:definition, "foo")
|
269
270
|
@resource.environment.known_resource_types.add @type
|
271
|
+
Puppet.push_context(:loaders => compiler.loaders)
|
272
|
+
end
|
273
|
+
|
274
|
+
after(:each) do
|
275
|
+
Puppet.pop_context
|
270
276
|
end
|
271
277
|
|
272
278
|
['module_name', 'name', 'title'].each do |variable|
|