File tree Expand file tree Collapse file tree 2 files changed +42
-0
lines changed Expand file tree Collapse file tree 2 files changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,16 @@ def register(schema)
1818 end
1919 module_function :register # rubocop:disable Style/AccessModifierDeclarations
2020
21+ # retrieve a Hash of transport schemas, keyed by their name.
22+ def list
23+ if @transports
24+ Marshal . load ( Marshal . dump ( @transports ) )
25+ else
26+ { }
27+ end
28+ end
29+ module_function :list # rubocop:disable Style/AccessModifierDeclarations
30+
2131 def connect ( name , connection_info )
2232 validate ( name , connection_info )
2333 require "puppet/transport/#{ name } "
Original file line number Diff line number Diff line change 8888 end
8989 end
9090
91+ describe '#list' do
92+ subject { described_class . list }
93+
94+ context 'with no transports registered' do
95+ it { is_expected . to eq ( { } ) }
96+ end
97+
98+ context 'with a transport registered' do
99+ let ( :schema ) do
100+ {
101+ name : 'test_target' ,
102+ desc : 'a basic transport' ,
103+ connection_info : {
104+ host : {
105+ type : 'String' ,
106+ desc : 'the host ip address or hostname' ,
107+ } ,
108+ } ,
109+ }
110+ end
111+
112+ before ( :each ) do
113+ described_class . register ( schema )
114+ end
115+
116+ it { expect ( described_class . list [ 'test_target' ] . definition ) . to eq schema }
117+ it 'returns a new object' do
118+ expect ( described_class . list [ 'test_target' ] . definition . object_id ) . not_to eq schema . object_id
119+ end
120+ end
121+ end
122+
91123 describe '#connect(name, connection_info)' , agent_test : true do
92124 let ( :name ) { 'test_target' }
93125 let ( :schema ) do
You can’t perform that action at this time.
0 commit comments