From f203b4f62f1e3a324d480c00f6d17f71b43b3fc9 Mon Sep 17 00:00:00 2001 From: Sean Millichamp Date: Fri, 21 Jul 2023 07:35:06 -0400 Subject: [PATCH] Restore documented puppetdb_query BoltSpec mocking The documented (and previous to PR #3092 working) puppetdb_client mocking expected only a single value to the function (the query). This change restores that behavior. !bug * Restore documented BoltSpec puppetdb_query mocking behavior --- .../boltlib/lib/puppet/functions/puppetdb_query.rb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/bolt-modules/boltlib/lib/puppet/functions/puppetdb_query.rb b/bolt-modules/boltlib/lib/puppet/functions/puppetdb_query.rb index 22b3a1894a..f3d415d106 100644 --- a/bolt-modules/boltlib/lib/puppet/functions/puppetdb_query.rb +++ b/bolt-modules/boltlib/lib/puppet/functions/puppetdb_query.rb @@ -37,16 +37,21 @@ # The query type could be more specific ASTQuery = Array[Variant[String, ASTQuery]] def make_query(query) - make_query_with_instance(query, nil) + puppetdb_client.make_query(query) end def make_query_with_instance(query, instance) + puppetdb_client.make_query(query, nil, instance) + end + + private + + def puppetdb_client puppetdb_client = Puppet.lookup(:bolt_pdb_client) # Bolt executor not expected when invoked from apply block executor = Puppet.lookup(:bolt_executor) { nil } # Send Analytics Report executor&.report_function_call(self.class.name) - - puppetdb_client.make_query(query, nil, instance) + puppetdb_client end end