Skip to content

Commit

Permalink
(FM-7691) Add context parameter for test transport
Browse files Browse the repository at this point in the history
This find other places where we need to handle passing a context
  • Loading branch information
DavidS committed Jan 25, 2019
1 parent e25922c commit 0a04d4e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/puppet/resource_api/transport/wrapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def initialize(name, url_or_config)

def facts
# @transport.facts + custom_facts # look into custom facts work by TP
@transport.facts
@transport.facts(nil)
end

def respond_to_missing?(name, _include_private)
Expand Down
8 changes: 4 additions & 4 deletions spec/fixtures/test_module/lib/puppet/transport/test_device.rb
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
module Puppet::Transport
# a transport for a test_device
class TestDevice
def initialize(connection_info);
def initialize(_context, connection_info);
puts connection_info
end

def facts
def facts(_context)
{ 'foo' => 'bar' }
end

def verify
def verify(_context)
return true
end

def close
def close(_context)
return
end
end
Expand Down
5 changes: 3 additions & 2 deletions spec/puppet/resource_api/transport/wrapper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

it 'will return the facts provided by the transport' do
allow(Puppet::ResourceApi::Transport).to receive(:connect).and_return(transport)
allow(transport).to receive(:facts).and_return(facts)
allow(transport).to receive(:facts).with(nil).and_return(facts)

expect(instance.facts).to eq(facts)
end
Expand All @@ -53,12 +53,13 @@
context 'when the transport can handle the method' do
let(:instance) { described_class.new('wibble', {}) }
let(:transport) { instance_double(Puppet::Transport::TestDevice, 'transport') }
let(:context) { instance_double(Puppet::ResourceApi::PuppetContext, 'context') }

it 'will return the facts provided by the transport' do
allow(Puppet::ResourceApi::Transport).to receive(:connect).and_return(transport)
expect(transport).to receive(:close)

instance.close
instance.close(context)
end
end

Expand Down

0 comments on commit 0a04d4e

Please sign in to comment.