]> gitweb.fluxo.info Git - puppet-sshkeys_core.git/commitdiff
Account for pre-5 behavior
authorJosh Cooper <josh@puppet.com>
Wed, 28 Nov 2018 00:49:54 +0000 (16:49 -0800)
committerJosh Cooper <josh@puppet.com>
Wed, 28 Nov 2018 19:45:17 +0000 (11:45 -0800)
In Puppet4, the Report class requires a kind argument. Also the is_to_s
and should_to_s methods returned an array of strings and a flattened
array as a string. That behavior was changed in PUP-7616 (commit
c14b28f9c427) so that both methods return a string as the name
implies.

spec/lib/puppet_spec/compiler.rb
spec/unit/type/ssh_authorized_key_spec.rb

index 49a65349c74216729121fe8bfb26f809fc1d28e1..4170b314ce23cc719ca2a2daaa5538871dbd1bbf 100644 (file)
@@ -29,12 +29,16 @@ module PuppetSpec::Compiler
   end
 
   def apply_compiled_manifest(manifest, prioritizer = Puppet::Graph::SequentialPrioritizer.new)
+    args = []
+    if Puppet.version.to_f < 5.0
+      args << 'apply'
+    end
     catalog = compile_to_ral(manifest)
     if block_given?
       catalog.resources.each { |res| yield res }
     end
     transaction = Puppet::Transaction.new(catalog,
-                                          Puppet::Transaction::Report.new,
+                                          Puppet::Transaction::Report.new(*args),
                                           prioritizer)
     transaction.evaluate
     transaction.report.finalize_report
index e375f580df4aa9e55a94b4a7a82c4f33349fed93..866c688064e0aef1b8d69868d4a0f1f713f5285c 100644 (file)
@@ -141,12 +141,14 @@ describe Puppet::Type.type(:ssh_authorized_key), unless: Puppet.features.microso
 
       it 'property should return well formed string of arrays from is_to_s' do
         resource = described_class.new(name: 'whev', type: :rsa, user: 'nobody', options: ['a', 'b', 'c'])
-        expect(resource.property(:options).is_to_s(['a', 'b', 'c'])).to eq "['a', 'b', 'c']"
+        str = (Puppet.version.to_f < 5.0) ? ['a', 'b', 'c'] : "['a', 'b', 'c']"
+        expect(resource.property(:options).is_to_s(['a', 'b', 'c'])).to eq(str)
       end
 
       it 'property should return well formed string of arrays from should_to_s' do
         resource = described_class.new(name: 'whev', type: :rsa, user: 'nobody', options: ['a', 'b', 'c'])
-        expect(resource.property(:options).should_to_s(['a', 'b', 'c'])).to eq "['a', 'b', 'c']"
+        str = (Puppet.version.to_f < 5.0) ? 'a b c' : "['a', 'b', 'c']"
+        expect(resource.property(:options).should_to_s(['a', 'b', 'c'])).to eq(str)
       end
     end