Skip to content

Commit b3a5bbc

Browse files
committed
Fix rhsm_repo to not raise exception when not registered
1 parent b27bf2f commit b3a5bbc

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lib/puppet/provider/rhsm_repo/subscription_manager.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def destroy
3333

3434
def self.instances
3535
repos = read_repos
36-
if repos.nil? || repos == []
36+
if repos.nil? || repos == [] || repos == [{}]
3737
[]
3838
else
3939
repos.map do |repo|

spec/unit/provider/rhsm_repo/subscription_manager_spec.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,12 @@
109109
repos = provider.class.instances
110110
expect(repos.size).to eq(0)
111111
end
112+
it 'returns nothing for not subscribed' do
113+
data = 'This system has no repositories available through subscriptions.'
114+
expect(provider.class).to receive(:subscription_manager).with('repos').and_return(data)
115+
repos = provider.class.instances
116+
expect(repos.size).to eq(0)
117+
end
112118
end
113119

114120
describe 'self.prefetch' do

0 commit comments

Comments
 (0)