From 81d1e0785d89847442315d58642d0d81ace38bfd Mon Sep 17 00:00:00 2001 From: othalla Date: Fri, 11 Jan 2019 09:49:47 +0100 Subject: [PATCH] Adding tests for haproxy scrape_uri Add & refactor haproxy scraping uri tests --- spec/classes/haproxy_exporter_spec.rb | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/spec/classes/haproxy_exporter_spec.rb b/spec/classes/haproxy_exporter_spec.rb index 8806ef9e8..4532b42fc 100644 --- a/spec/classes/haproxy_exporter_spec.rb +++ b/spec/classes/haproxy_exporter_spec.rb @@ -27,7 +27,7 @@ it { is_expected.to contain_prometheus__daemon('haproxy_exporter') } end - context 'with unix socket as scraping url' do + context 'with custom scraping uri' do let(:params) do { cnf_scrape_uri: 'unix:/var/haproxy/listen.sock', @@ -38,11 +38,21 @@ } end - it { is_expected.to compile.with_all_deps } - it { is_expected.to contain_class('prometheus') } - it { is_expected.to contain_user('haproxy-user') } - it { is_expected.to contain_group('haproxy-exporter') } - it { is_expected.to contain_prometheus__daemon('haproxy_exporter') } + context 'unix socket' do + let(:params) do + super().merge(cnf_scrape_uri: 'unix:/var/haproxy/listen.sock') + end + + it { is_expected.to compile.with_all_deps } + end + + context 'bad format' do + let(:params) do + super().merge(cnf_scrape_uri: 'nosocket:/not/a/socket.format') + end + + it { is_expected.to raise_error(Puppet::Error) } + end end end end