Skip to content

Commit

Permalink
Fix type error on zabbix_proxy delete
Browse files Browse the repository at this point in the history
zbx.proxies.delete expects an array, we handed over a string. This fixes
it a adds proper tests.
  • Loading branch information
baurmatt committed Apr 14, 2020
1 parent 904f89a commit 9f956cb
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/puppet/provider/zabbix_proxy/ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def exists?
end

def destroy
zbx.proxies.delete(zbx.proxies.get_id(host: @resource[:hostname]))
zbx.proxies.delete([zbx.proxies.get_id(host: @resource[:hostname])].flatten)
end

mk_resource_methods
Expand Down
45 changes: 45 additions & 0 deletions spec/acceptance/zabbix_proxy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,49 @@ class { 'zabbix':
end
end
end

context 'delete zabbix_proxy resources' do
it 'runs successfully' do
# This will delete the Zabbix proxies create above
pp = <<-EOS
zabbix_proxy { 'ZabbixProxy1':
ensure => absent,
ipaddress => '127.0.0.1',
use_ip => true,
mode => 0,
port => 10051,
}
zabbix_proxy { 'ZabbixProxy2':
ensure => absent,
ipaddress => '127.0.0.3',
use_ip => false,
mode => 1,
port => 10055,
}
EOS

apply_manifest(pp, catch_failures: true)
end

let(:result_proxies) do
zabbixapi('localhost', 'Admin', 'zabbix', 'proxy.get', selectInterface: %w[dns ip port useip],
output: ['host']).result
end

context 'ZabbixProxy1' do
let(:proxy1) { result_proxies.select { |h| h['host'] == 'ZabbixProxy1' }.first }

it "doesn't exist" do
expect(proxy1).to eq(nil)
end
end

context 'ZabbixProxy2' do
let(:proxy2) { result_proxies.select { |h| h['host'] == 'ZabbixProxy2' }.first }

it "doesn't exist" do
expect(proxy2).to eq(nil)
end
end
end
end

0 comments on commit 9f956cb

Please sign in to comment.