Skip to content

Commit ccc4bd8

Browse files
committed
(FM-7691) pass a context to transport.facts
This uses the initial `list` implementation from the previous commit to access the schema to create a context to pass around.
1 parent c01ad89 commit ccc4bd8

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

lib/puppet/resource_api/transport/wrapper.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@ def initialize(name, url_or_config)
1717
end
1818

1919
@transport = Puppet::ResourceApi::Transport.connect(name, config)
20+
@schema = Puppet::ResourceApi::Transport.list[name]
2021
end
2122

2223
def facts
24+
context = Puppet::ResourceApi::PuppetContext.new(@schema)
2325
# @transport.facts + custom_facts # look into custom facts work by TP
24-
@transport.facts(nil)
26+
@transport.facts(context)
2527
end
2628

2729
def respond_to_missing?(name, _include_private)

spec/puppet/resource_api/transport/wrapper_spec.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,15 @@
3737
describe '#facts' do
3838
context 'when called' do
3939
let(:instance) { described_class.new('wibble', {}) }
40+
let(:context) { instance_double(Puppet::ResourceApi::PuppetContext, 'context') }
4041
let(:facts) { { 'foo' => 'bar' } }
4142
let(:transport) { instance_double(Puppet::Transport::TestDevice, 'transport') }
4243

4344
it 'will return the facts provided by the transport' do
4445
allow(Puppet::ResourceApi::Transport).to receive(:connect).and_return(transport)
45-
allow(transport).to receive(:facts).with(nil).and_return(facts)
46+
allow(Puppet::ResourceApi::Transport).to receive(:list).and_return(schema: :dummy)
47+
allow(Puppet::ResourceApi::PuppetContext).to receive(:new).and_return(context)
48+
allow(transport).to receive(:facts).with(context).and_return(facts)
4649

4750
expect(instance.facts).to eq(facts)
4851
end

0 commit comments

Comments
 (0)