Skip to content

Commit c6645c5

Browse files
committed
03c test added
1 parent ccf8105 commit c6645c5

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

spec/acceptance/deferred_spec.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ def read_win_file_if_exists(path)
2828
let(:control_manifest) { read_fixture('01_file_deferred.pp') }
2929
let(:dsc_deferred_direct) { read_fixture('02_dsc_deferred_direct.pp') }
3030
let(:dsc_deferred_inline) { read_fixture('02b_dsc_deferred_inline.pp') } # ← NEW
31+
let(:dsc_deferred_epp_inline) { read_fixture('02c_dsc_deferred_epp_inline.pp') } # ← NEW
3132
let(:dsc_deferred_stringified) { read_fixture('03a_dsc_deferred_stringified.pp') }
3233
let(:dsc_deferred_bad_unwrap) { read_fixture('03b_dsc_deferred_bad_unwrap.pp') }
3334

@@ -66,6 +67,20 @@ def read_win_file_if_exists(path)
6667
end
6768
end
6869

70+
# NEW 02c: inline Deferred on the DSC property (no variable intermediary)
71+
it '02c: passing a Deferred inline whilke calling an epp' do
72+
apply = apply_manifest_debug(dsc_deferred_inline)
73+
out = read_win_file_if_exists('C:/Temp/from_dsc_inline.txt')
74+
content = out[:content].strip
75+
if out[:exists] && content == 'hello-dsc-epp'
76+
expect(true).to be(true)
77+
elsif out[:exists] && content =~ %r{Deferred\s*\(|Puppet::Pops::Types::Deferred}i
78+
raise "BUG: 02c wrote stringified Deferred: #{content.inspect}\nApply:\n#{apply.stdout}#{apply.stderr}"
79+
else
80+
raise "Unexpected 02c outcome. Exists=#{out[:exists]} Content=#{content.inspect}\nApply:\n#{apply.stdout}#{apply.stderr}"
81+
end
82+
end
83+
6984
it '03a: stringifying a Deferred writes the function form (reproduces customer report)' do
7085
apply_manifest_debug(dsc_deferred_stringified)
7186
out = read_win_file_if_exists('C:/Temp/from_dsc_var_string.txt')
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# spec/fixtures/manifests/02_dsc_deferred_direct.pp
2+
file { 'C:/Temp':
3+
ensure => directory,
4+
}
5+
6+
$deferred = Deferred('join', [['hello','-','dsc', '-', 'epp'], ''])
7+
8+
dsc { 'WriteFileViaDSC':
9+
resource_name => 'File',
10+
module => 'PSDesiredStateConfiguration',
11+
properties => {
12+
'DestinationPath' => 'C:\Temp\from_dsc.txt',
13+
'Type' => 'File',
14+
'Ensure' => 'Present',
15+
'Contents' => Deferred('inline_epp', ['<%= $content.unwrap %>', { content => $deferred }]),
16+
},
17+
require => File['C:/Temp'],
18+
}

0 commit comments

Comments
 (0)