From 33ac076ff4fe44b189b3c8e88ac5f61af9b61bd5 Mon Sep 17 00:00:00 2001 From: Leo Arnold Date: Tue, 23 Apr 2019 00:50:11 +0200 Subject: [PATCH] Add missing tests --- .github/README.md | 2 +- README.md.erb | 2 +- manifests/init.pp | 4 ++-- spec/classes/init_spec.rb | 42 +++++++++++++++++++++++++++++++++ templates/cupsd/_directives.erb | 2 +- 5 files changed, 47 insertions(+), 5 deletions(-) diff --git a/.github/README.md b/.github/README.md index 43646265..4d71bd62 100644 --- a/.github/README.md +++ b/.github/README.md @@ -517,7 +517,7 @@ Installs, configures, and manages the CUPS service. } ``` -* `log_debug_level`: Sets the `LogDebugLevel` directive of the CUPS server. +* `log_debug_history`: Sets the `LogDebugHistory` directive of the CUPS server. * `log_level`: Sets the `LogLevel` directive of the CUPS server. diff --git a/README.md.erb b/README.md.erb index 525199c1..944f548a 100644 --- a/README.md.erb +++ b/README.md.erb @@ -519,7 +519,7 @@ Installs, configures, and manages the CUPS service. } ``` -* `log_debug_level`: Sets the `LogDebugLevel` directive of the CUPS server. +* `log_debug_history`: Sets the `LogDebugHistory` directive of the CUPS server. * `log_level`: Sets the `LogLevel` directive of the CUPS server. diff --git a/manifests/init.pp b/manifests/init.pp index 127732bc..aac60d8f 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -37,7 +37,7 @@ # Note that the `cupsd.conf` directive `Port 631` is equivalent to `Listen *:631`. # *Warning*: For this module to work, it is *mandatory* that CUPS is listening on `localhost:631`. # @param location Sets the access control lists for the CUPS web interface. Restricts access to localhost by default. -# @param log_debug_level Sets the `LogDebugLevel` directive of the CUPS server. +# @param log_debug_history Sets the `LogDebugHistory` directive of the CUPS server. # @param log_level Sets the `LogLevel` directive of the CUPS server. # @param log_time_format Sets the `LogTimeFormat` directive of the CUPS server. # @param max_clients Specifies the maximum number of simultaneous clients to support. @@ -70,7 +70,7 @@ Optional[String] $default_queue = undef, Variant[String, Array[String]] $listen = ['localhost:631', '/var/run/cups/cups.sock'], Optional[Variant[String, Hash]] $location = undef, - Optional[Integer] $log_debug_level = undef, + Optional[Integer] $log_debug_history = undef, Optional[String] $log_level = undef, Optional[String] $log_time_format = undef, Optional[Integer] $max_clients = undef, diff --git a/spec/classes/init_spec.rb b/spec/classes/init_spec.rb index 8cdcc90e..03d64ed7 100644 --- a/spec/classes/init_spec.rb +++ b/spec/classes/init_spec.rb @@ -293,6 +293,48 @@ end end + describe 'log_debug_history' do + let(:facts) { any_supported_os } + + context 'when not set' do + it { is_expected.to_not contain_file('/etc/cups/cupsd.conf').with(content: /^LogDebugHistory/) } + end + + context 'when set to 5' do + let(:params) { { log_debug_history: 5 } } + + it { is_expected.to contain_file('/etc/cups/cupsd.conf').with(content: /^LogDebugHistory 5$/) } + end + end + + describe 'log_level' do + let(:facts) { any_supported_os } + + context 'when not set' do + it { is_expected.to_not contain_file('/etc/cups/cupsd.conf').with(content: /^LogLevel/) } + end + + context "when set to 'debug2'" do + let(:params) { { log_level: 'debug2' } } + + it { is_expected.to contain_file('/etc/cups/cupsd.conf').with(content: /^LogLevel debug2$/) } + end + end + + describe 'log_time_format' do + let(:facts) { any_supported_os } + + context 'when not set' do + it { is_expected.to_not contain_file('/etc/cups/cupsd.conf').with(content: /^LogTimeFormat/) } + end + + context "when set to 'usecs'" do + let(:params) { { log_time_format: 'usecs' } } + + it { is_expected.to contain_file('/etc/cups/cupsd.conf').with(content: /^LogTimeFormat usecs$/) } + end + end + describe 'max_clients' do let(:facts) { any_supported_os } diff --git a/templates/cupsd/_directives.erb b/templates/cupsd/_directives.erb index 8ef7a170..bd77205d 100644 --- a/templates/cupsd/_directives.erb +++ b/templates/cupsd/_directives.erb @@ -10,7 +10,7 @@ DefaultAuthType Basic <%= "Listen #{l}" %> <% end -%> <% end -%> -<%= COMMENT_OUT if @log_debug_level.nil? -%>LogDebugLevel <%= @log_debug_level %> +<%= COMMENT_OUT if @log_debug_history.nil? -%>LogDebugHistory <%= @log_debug_history %> <%= COMMENT_OUT if @log_level.nil? -%>LogLevel <%= @log_level %> <%= COMMENT_OUT if @log_time_format.nil? -%>LogTimeFormat <%= @log_time_format %> <%= COMMENT_OUT if @max_clients.nil? -%>MaxClients <%= @max_clients %>