Debian Codegraph @

spec/defines/rule_spec.rb

raw symbols SCIP
1 require 'spec_helper'
2
3 describe 'logrotate::rule' do
4 context 'with an alphanumeric title' do
5 let(:title) { 'test' }
6
7 context 'and ensure => absent' do
8 let(:params) { {:ensure => 'absent'} }
9
10 it do
11 should contain_file('/etc/logrotate.d/test').with_ensure('absent')
12 end
13 end
14
15 let(:params) { {:path => '/var/log/foo.log'} }
16 it do
17 should include_class('logrotate::base')
18 should contain_file('/etc/logrotate.d/test').with({
19 'owner' => 'root',
20 'group' => 'root',
21 'ensure' => 'present',
22 'mode' => '0444',
23 }).with_content("/var/log/foo.log {\n}\n")
24 end
25
26 context 'with an array path' do
27 let (:params) { {:path => ['/var/log/foo1.log','/var/log/foo2.log']} }
28 it do
29 should contain_file('/etc/logrotate.d/test').with_content(
30 "/var/log/foo1.log /var/log/foo2.log {\n}\n"
31 )
32 end
33 end
34
35 ###########################################################################
36 # COMPRESS
37 context 'and compress => true' do
38 let(:params) {
39 {:path => '/var/log/foo.log', :compress => true}
40 }
41
42 it do
43 should contain_file('/etc/logrotate.d/test') \
44 .with_content(/^ compress$/)
45 end
46 end
47
48 context 'and compress => false' do
49 let(:params) {
50 {:path => '/var/log/foo.log', :compress => false}
51 }
52
53 it do
54 should contain_file('/etc/logrotate.d/test') \
55 .with_content(/^ nocompress$/)
56 end
57 end
58
59 context 'and compress => foo' do
60 let(:params) {
61 {:path => '/var/log/foo.log', :compress => 'foo'}
62 }
63
64 it do
65 expect {
66 should contain_file('/etc/logrotate.d/test')
67 }.to raise_error(Puppet::Error, /compress must be a boolean/)
68 end
69 end
70
71 ###########################################################################
72 # COMPRESSCMD
73 context 'and compresscmd => bzip2' do
74 let(:params) {
75 {:path => '/var/log/foo.log', :compresscmd => 'bzip2'}
76 }
77
78 it do
79 should contain_file('/etc/logrotate.d/test') \
80 .with_content(/^ compresscmd bzip2$/)
81 end
82 end
83
84 ###########################################################################
85 # COMPRESSEXT
86 context 'and compressext => .bz2' do
87 let(:params) {
88 {:path => '/var/log/foo.log', :compressext => '.bz2'}
89 }
90
91 it do
92 should contain_file('/etc/logrotate.d/test') \
93 .with_content(/^ compressext .bz2$/)
94 end
95 end
96
97 ###########################################################################
98 # COMPRESSOPTIONS
99 context 'and compressoptions => -9' do
100 let(:params) {
101 {:path => '/var/log/foo.log', :compressoptions => '-9'}
102 }
103
104 it do
105 should contain_file('/etc/logrotate.d/test') \
106 .with_content(/^ compressoptions -9$/)
107 end
108 end
109
110 ###########################################################################
111 # COPY
112 context 'and copy => true' do
113 let(:params) {
114 {:path => '/var/log/foo.log', :copy => true}
115 }
116
117 it do
118 should contain_file('/etc/logrotate.d/test').with_content(/^ copy$/)
119 end
120 end
121
122 context 'and copy => false' do
123 let(:params) {
124 {:path => '/var/log/foo.log', :copy => false}
125 }
126
127 it do
128 should contain_file('/etc/logrotate.d/test').with_content(/^ nocopy$/)
129 end
130 end
131
132 context 'and copy => foo' do
133 let(:params) {
134 {:path => '/var/log/foo.log', :copy => 'foo'}
135 }
136
137 it do
138 expect {
139 should contain_file('/etc/logrotate.d/test')
140 }.to raise_error(Puppet::Error, /copy must be a boolean/)
141 end
142 end
143
144 ###########################################################################
145 # COPYTRUNCATE
146 context 'and copytruncate => true' do
147 let(:params) {
148 {:path => '/var/log/foo.log', :copytruncate => true}
149 }
150
151 it do
152 should contain_file('/etc/logrotate.d/test') \
153 .with_content(/^ copytruncate$/)
154 end
155 end
156
157 context 'and copytruncate => false' do
158 let(:params) {
159 {:path => '/var/log/foo.log', :copytruncate => false}
160 }
161
162 it do
163 should contain_file('/etc/logrotate.d/test') \
164 .with_content(/^ nocopytruncate$/)
165 end
166 end
167
168 context 'and copytruncate => foo' do
169 let(:params) {
170 {:path => '/var/log/foo.log', :copytruncate => 'foo'}
171 }
172
173 it do
174 expect {
175 should contain_file('/etc/logrotate.d/test')
176 }.to raise_error(Puppet::Error, /copytruncate must be a boolean/)
177 end
178 end
179
180 ###########################################################################
181 # CREATE / CREATE_MODE / CREATE_OWNER / CREATE_GROUP
182 context 'and create => true' do
183 let(:params) {
184 {:path => '/var/log/foo.log', :create => true}
185 }
186
187 it do
188 should contain_file('/etc/logrotate.d/test') \
189 .with_content(/^ create$/)
190 end
191
192 context 'and create_mode => 0777' do
193 let(:params) {
194 {
195 :path => '/var/log/foo.log',
196 :create => true,
197 :create_mode => '0777',
198 }
199 }
200
201 it do
202 should contain_file('/etc/logrotate.d/test') \
203 .with_content(/^ create 0777$/)
204 end
205
206 context 'and create_owner => www-data' do
207 let(:params) {
208 {
209 :path => '/var/log/foo.log',
210 :create => true,
211 :create_mode => '0777',
212 :create_owner => 'www-data',
213 }
214 }
215
216 it do
217 should contain_file('/etc/logrotate.d/test') \
218 .with_content(/^ create 0777 www-data/)
219 end
220
221 context 'and create_group => admin' do
222 let(:params) {
223 {
224 :path => '/var/log/foo.log',
225 :create => true,
226 :create_mode => '0777',
227 :create_owner => 'www-data',
228 :create_group => 'admin',
229 }
230 }
231
232 it do
233 should contain_file('/etc/logrotate.d/test') \
234 .with_content(/^ create 0777 www-data admin$/)
235 end
236 end
237 end
238
239 context 'and create_group => admin' do
240 let(:params) {
241 {
242 :path => '/var/log/foo.log',
243 :create => true,
244 :create_mode => '0777',
245 :create_group => 'admin',
246 }
247 }
248
249 it do
250 expect {
251 should contain_file('/etc/logrotate.d/test')
252 }.to raise_error(Puppet::Error, /create_group requires create_owner/)
253 end
254 end
255 end
256
257 context 'and create_owner => www-data' do
258 let(:params) {
259 {
260 :path => '/var/log/foo.log',
261 :create => true,
262 :create_owner => 'www-data',
263 }
264 }
265
266 it do
267 expect {
268 should contain_file('/etc/logrotate.d/test')
269 }.to raise_error(Puppet::Error, /create_owner requires create_mode/)
270 end
271 end
272 end
273
274 context 'and create => false' do
275 let(:params) {
276 {:path => '/var/log/foo.log', :create => false}
277 }
278
279 it do
280 should contain_file('/etc/logrotate.d/test') \
281 .with_content(/^ nocreate$/)
282 end
283
284 context 'and create_mode => 0777' do
285 let(:params) {
286 {
287 :path => '/var/log/foo.log',
288 :create => false,
289 :create_mode => '0777',
290 }
291 }
292
293 it do
294 expect {
295 should contain_file('/etc/logrotate.d/test')
296 }.to raise_error(Puppet::Error, /create_mode requires create/)
297 end
298 end
299 end
300
301 context 'and create => foo' do
302 let(:params) {
303 {:path => '/var/log/foo.log', :create => 'foo'}
304 }
305
306 it do
307 expect {
308 should contain_file('/etc/logrotate.d/test')
309 }.to raise_error(Puppet::Error, /create must be a boolean/)
310 end
311 end
312
313 ###########################################################################
314 # DATEEXT
315 context 'and dateext => true' do
316 let(:params) {
317 {:path => '/var/log/foo.log', :dateext => true}
318 }
319
320 it do
321 should contain_file('/etc/logrotate.d/test') \
322 .with_content(/^ dateext$/)
323 end
324 end
325
326 context 'and dateext => false' do
327 let(:params) {
328 {:path => '/var/log/foo.log', :dateext => false}
329 }
330
331 it do
332 should contain_file('/etc/logrotate.d/test') \
333 .with_content(/^ nodateext$/)
334 end
335 end
336
337 context 'and dateext => foo' do
338 let(:params) {
339 {:path => '/var/log/foo.log', :dateext => 'foo'}
340 }
341
342 it do
343 expect {
344 should contain_file('/etc/logrotate.d/test')
345 }.to raise_error(Puppet::Error, /dateext must be a boolean/)
346 end
347 end
348
349 ###########################################################################
350 # DATEFORMAT
351 context 'and dateformat => -%Y%m%d' do
352 let(:params) {
353 {:path => '/var/log/foo.log', :dateformat => '-%Y%m%d'}
354 }
355
356 it do
357 should contain_file('/etc/logrotate.d/test') \
358 .with_content(/^ dateformat -%Y%m%d$/)
359 end
360 end
361
362 ###########################################################################
363 # DELAYCOMPRESS
364 context 'and delaycompress => true' do
365 let(:params) {
366 {:path => '/var/log/foo.log', :delaycompress => true}
367 }
368
369 it do
370 should contain_file('/etc/logrotate.d/test') \
371 .with_content(/^ delaycompress$/)
372 end
373 end
374
375 context 'and delaycompress => false' do
376 let(:params) {
377 {:path => '/var/log/foo.log', :delaycompress => false}
378 }
379
380 it do
381 should contain_file('/etc/logrotate.d/test') \
382 .with_content(/^ nodelaycompress$/)
383 end
384 end
385
386 context 'and delaycompress => foo' do
387 let(:params) {
388 {:path => '/var/log/foo.log', :delaycompress => 'foo'}
389 }
390
391 it do
392 expect {
393 should contain_file('/etc/logrotate.d/test')
394 }.to raise_error(Puppet::Error, /delaycompress must be a boolean/)
395 end
396 end
397
398 ###########################################################################
399 # EXTENSION
400 context 'and extension => foo' do
401 let(:params) {
402 {:path => '/var/log/foo.log', :extension => '.foo'}
403 }
404
405 it do
406 should contain_file('/etc/logrotate.d/test') \
407 .with_content(/^ extension \.foo$/)
408 end
409 end
410
411 ###########################################################################
412 # IFEMPTY
413 context 'and ifempty => true' do
414 let(:params) {
415 {:path => '/var/log/foo.log', :ifempty => true}
416 }
417
418 it do
419 should contain_file('/etc/logrotate.d/test') \
420 .with_content(/^ ifempty$/)
421 end
422 end
423
424 context 'and ifempty => false' do
425 let(:params) {
426 {:path => '/var/log/foo.log', :ifempty => false}
427 }
428
429 it do
430 should contain_file('/etc/logrotate.d/test') \
431 .with_content(/^ notifempty$/)
432 end
433 end
434
435 context 'and ifempty => foo' do
436 let(:params) {
437 {:path => '/var/log/foo.log', :ifempty => 'foo'}
438 }
439
440 it do
441 expect {
442 should contain_file('/etc/logrotate.d/test')
443 }.to raise_error(Puppet::Error, /ifempty must be a boolean/)
444 end
445 end
446
447 ###########################################################################
448 # MAIL / MAILFIRST / MAILLAST
449 context 'and mail => test.example.com' do
450 let(:params) {
451 {:path => '/var/log/foo.log', :mail => '[email protected]'}
452 }
453
454 it do
455 should contain_file('/etc/logrotate.d/test') \
456 .with_content(/^ mail [email protected]$/)
457 end
458
459 context 'and mailfirst => true' do
460 let(:params) {
461 {
462 :path => '/var/log/foo.log',
463 :mail => '[email protected]',
464 :mailfirst => true,
465 }
466 }
467
468 it do
469 should contain_file('/etc/logrotate.d/test') \
470 .with_content(/^ mailfirst$/)
471 end
472
473 context 'and maillast => true' do
474 let(:params) {
475 {
476 :path => '/var/log/foo.log',
477 :mail => '[email protected]',
478 :mailfirst => true,
479 :maillast => true,
480 }
481 }
482
483 it do
484 expect {
485 should contain_file('/etc/logrotate.d/test')
486 }.to raise_error(Puppet::Error, /set both mailfirst and maillast/)
487 end
488 end
489 end
490
491 context 'and maillast => true' do
492 let(:params) {
493 {
494 :path => '/var/log/foo.log',
495 :mail => '[email protected]',
496 :maillast => true,
497 }
498 }
499
500 it do
501 should contain_file('/etc/logrotate.d/test') \
502 .with_content(/^ maillast$/)
503 end
504 end
505 end
506
507 context 'and mail => false' do
508 let(:params) {
509 {:path => '/var/log/foo.log', :mail => false}
510 }
511
512 it do
513 should contain_file('/etc/logrotate.d/test') \
514 .with_content(/^ nomail$/)
515 end
516 end
517
518 ###########################################################################
519 # MAXAGE
520 context 'and maxage => 3' do
521 let(:params) {
522 {:path => '/var/log/foo.log', :maxage => 3}
523 }
524
525 it do
526 should contain_file('/etc/logrotate.d/test') \
527 .with_content(/^ maxage 3$/)
528 end
529 end
530
531 context 'and maxage => foo' do
532 let(:params) {
533 {:path => '/var/log/foo.log', :maxage => 'foo'}
534 }
535
536 it do
537 expect {
538 should contain_file('/etc/logrotate.d/test')
539 }.to raise_error(Puppet::Error, /maxage must be an integer/)
540 end
541 end
542
543 ###########################################################################
544 # MINSIZE
545 context 'and minsize => 100' do
546 let(:params) {
547 {:path => '/var/log/foo.log', :minsize => 100}
548 }
549
550 it do
551 should contain_file('/etc/logrotate.d/test') \
552 .with_content(/^ minsize 100$/)
553 end
554 end
555
556 context 'and minsize => 100k' do
557 let(:params) {
558 {:path => '/var/log/foo.log', :minsize => '100k'}
559 }
560
561 it do
562 should contain_file('/etc/logrotate.d/test') \
563 .with_content(/^ minsize 100k$/)
564 end
565 end
566
567 context 'and minsize => 100M' do
568 let(:params) {
569 {:path => '/var/log/foo.log', :minsize => '100M'}
570 }
571
572 it do
573 should contain_file('/etc/logrotate.d/test') \
574 .with_content(/^ minsize 100M$/)
575 end
576 end
577
578 context 'and minsize => 100G' do
579 let(:params) {
580 {:path => '/var/log/foo.log', :minsize => '100G'}
581 }
582
583 it do
584 should contain_file('/etc/logrotate.d/test') \
585 .with_content(/^ minsize 100G$/)
586 end
587 end
588
589 context 'and minsize => foo' do
590 let(:params) {
591 {:path => '/var/log/foo.log', :minsize => 'foo'}
592 }
593
594 it do
595 expect {
596 should contain_file('/etc/logrotate.d/test')
597 }.to raise_error(Puppet::Error, /minsize must match/)
598 end
599 end
600
601 ###########################################################################
602 # MISSINGOK
603 context 'and missingok => true' do
604 let(:params) {
605 {:path => '/var/log/foo.log', :missingok => true}
606 }
607
608 it do
609 should contain_file('/etc/logrotate.d/test') \
610 .with_content(/^ missingok$/)
611 end
612 end
613
614 context 'and missingok => false' do
615 let(:params) {
616 {:path => '/var/log/foo.log', :missingok => false}
617 }
618
619 it do
620 should contain_file('/etc/logrotate.d/test') \
621 .with_content(/^ nomissingok$/)
622 end
623 end
624
625 context 'and missingok => foo' do
626 let(:params) {
627 {:path => '/var/log/foo.log', :missingok => 'foo'}
628 }
629
630 it do
631 expect {
632 should contain_file('/etc/logrotate.d/test')
633 }.to raise_error(Puppet::Error, /missingok must be a boolean/)
634 end
635 end
636
637 ###########################################################################
638 # OLDDIR
639 context 'and olddir => /var/log/old' do
640 let(:params) {
641 {:path => '/var/log/foo.log', :olddir => '/var/log/old'}
642 }
643
644 it do
645 should contain_file('/etc/logrotate.d/test') \
646 .with_content(/^ olddir \/var\/log\/old$/)
647 end
648 end
649
650 context 'and olddir => false' do
651 let(:params) {
652 {:path => '/var/log/foo.log', :olddir => false}
653 }
654
655 it do
656 should contain_file('/etc/logrotate.d/test') \
657 .with_content(/^ noolddir$/)
658 end
659 end
660
661 ###########################################################################
662 # POSTROTATE
663 context 'and postrotate => /bin/true' do
664 let(:params) {
665 {:path => '/var/log/foo.log', :postrotate => '/bin/true'}
666 }
667
668 it do
669 should contain_file('/etc/logrotate.d/test') \
670 .with_content(/postrotate\n \/bin\/true\n endscript/)
671 end
672 end
673
674 ###########################################################################
675 # PREROTATE
676 context 'and prerotate => /bin/true' do
677 let(:params) {
678 {:path => '/var/log/foo.log', :prerotate => '/bin/true'}
679 }
680
681 it do
682 should contain_file('/etc/logrotate.d/test') \
683 .with_content(/prerotate\n \/bin\/true\n endscript/)
684 end
685 end
686
687 ###########################################################################
688 # FIRSTACTION
689 context 'and firstaction => /bin/true' do
690 let(:params) {
691 {:path => '/var/log/foo.log', :firstaction => '/bin/true'}
692 }
693
694 it do
695 should contain_file('/etc/logrotate.d/test') \
696 .with_content(/firstaction\n \/bin\/true\n endscript/)
697 end
698 end
699
700 ###########################################################################
701 # LASTACTION
702 context 'and lastaction => /bin/true' do
703 let(:params) {
704 {:path => '/var/log/foo.log', :lastaction => '/bin/true'}
705 }
706
707 it do
708 should contain_file('/etc/logrotate.d/test') \
709 .with_content(/lastaction\n \/bin\/true\n endscript/)
710 end
711 end
712
713 ###########################################################################
714 # ROTATE
715 context 'and rotate => 3' do
716 let(:params) {
717 {:path => '/var/log/foo.log', :rotate => 3}
718 }
719
720 it do
721 should contain_file('/etc/logrotate.d/test') \
722 .with_content(/^ rotate 3$/)
723 end
724 end
725
726 context 'and rotate => foo' do
727 let(:params) {
728 {:path => '/var/log/foo.log', :rotate => 'foo'}
729 }
730
731 it do
732 expect {
733 should contain_file('/etc/logrotate.d/test')
734 }.to raise_error(Puppet::Error, /rotate must be an integer/)
735 end
736 end
737
738 ###########################################################################
739 # ROTATE_EVERY
740 context 'and rotate_every => hour' do
741 let(:params) {
742 {:path => '/var/log/foo.log', :rotate_every => 'hour'}
743 }
744
745 it { should include_class('logrotate::hourly') }
746 it { should contain_file('/etc/logrotate.d/hourly/test') }
747 end
748
749 context 'and rotate_every => day' do
750 let(:params) {
751 {:path => '/var/log/foo.log', :rotate_every => 'day'}
752 }
753
754 it do
755 should contain_file('/etc/logrotate.d/test') \
756 .with_content(/^ daily$/)
757 end
758 end
759
760 context 'and rotate_every => week' do
761 let(:params) {
762 {:path => '/var/log/foo.log', :rotate_every => 'week'}
763 }
764
765 it do
766 should contain_file('/etc/logrotate.d/test') \
767 .with_content(/^ weekly$/)
768 end
769 end
770
771 context 'and rotate_every => month' do
772 let(:params) {
773 {:path => '/var/log/foo.log', :rotate_every => 'month'}
774 }
775
776 it do
777 should contain_file('/etc/logrotate.d/test') \
778 .with_content(/^ monthly$/)
779 end
780 end
781
782 context 'and rotate_every => year' do
783 let(:params) {
784 {:path => '/var/log/foo.log', :rotate_every => 'year'}
785 }
786
787 it do
788 should contain_file('/etc/logrotate.d/test') \
789 .with_content(/^ yearly$/)
790 end
791 end
792
793 context 'and rotate_every => foo' do
794 let(:params) {
795 {:path => '/var/log/foo.log', :rotate_every => 'foo'}
796 }
797
798 it do
799 expect {
800 should contain_file('/etc/logrotate.d/test')
801 }.to raise_error(Puppet::Error, /invalid rotate_every value/)
802 end
803 end
804
805 ###########################################################################
806 # SIZE
807 context 'and size => 100' do
808 let(:params) {
809 {:path => '/var/log/foo.log', :size => 100}
810 }
811
812 it do
813 should contain_file('/etc/logrotate.d/test') \
814 .with_content(/^ size 100$/)
815 end
816 end
817
818 context 'and size => 100k' do
819 let(:params) {
820 {:path => '/var/log/foo.log', :size => '100k'}
821 }
822
823 it do
824 should contain_file('/etc/logrotate.d/test') \
825 .with_content(/^ size 100k$/)
826 end
827 end
828
829 context 'and size => 100M' do
830 let(:params) {
831 {:path => '/var/log/foo.log', :size => '100M'}
832 }
833
834 it do
835 should contain_file('/etc/logrotate.d/test') \
836 .with_content(/^ size 100M$/)
837 end
838 end
839
840 context 'and size => 100G' do
841 let(:params) {
842 {:path => '/var/log/foo.log', :size => '100G'}
843 }
844
845 it do
846 should contain_file('/etc/logrotate.d/test') \
847 .with_content(/^ size 100G$/)
848 end
849 end
850
851 context 'and size => foo' do
852 let(:params) {
853 {:path => '/var/log/foo.log', :size => 'foo'}
854 }
855
856 it do
857 expect {
858 should contain_file('/etc/logrotate.d/test')
859 }.to raise_error(Puppet::Error, /size must match/)
860 end
861 end
862
863 ###########################################################################
864 # SHAREDSCRIPTS
865 context 'and sharedscripts => true' do
866 let(:params) {
867 {:path => '/var/log/foo.log', :sharedscripts => true}
868 }
869
870 it do
871 should contain_file('/etc/logrotate.d/test') \
872 .with_content(/^ sharedscripts$/)
873 end
874 end
875
876 context 'and sharedscripts => false' do
877 let(:params) {
878 {:path => '/var/log/foo.log', :sharedscripts => false}
879 }
880
881 it do
882 should contain_file('/etc/logrotate.d/test') \
883 .with_content(/^ nosharedscripts$/)
884 end
885 end
886
887 context 'and sharedscripts => foo' do
888 let(:params) {
889 {:path => '/var/log/foo.log', :sharedscripts => 'foo'}
890 }
891
892 it do
893 expect {
894 should contain_file('/etc/logrotate.d/test')
895 }.to raise_error(Puppet::Error, /sharedscripts must be a boolean/)
896 end
897 end
898
899 ###########################################################################
900 # SHRED / SHREDCYCLES
901 context 'and shred => true' do
902 let(:params) {
903 {:path => '/var/log/foo.log', :shred => true}
904 }
905
906 it do
907 should contain_file('/etc/logrotate.d/test') \
908 .with_content(/^ shred$/)
909 end
910
911 context 'and shredcycles => 3' do
912 let(:params) {
913 {:path => '/var/log/foo.log', :shred => true, :shredcycles => 3}
914 }
915
916 it do
917 should contain_file('/etc/logrotate.d/test') \
918 .with_content(/^ shredcycles 3$/)
919 end
920 end
921
922 context 'and shredcycles => foo' do
923 let(:params) {
924 {:path => '/var/log/foo.log', :shred => true, :shredcycles => 'foo'}
925 }
926
927 it do
928 expect {
929 should contain_file('/etc/logrotate.d/test')
930 }.to raise_error(Puppet::Error, /shredcycles must be an integer/)
931 end
932 end
933 end
934
935 context 'and shred => false' do
936 let(:params) {
937 {:path => '/var/log/foo.log', :shred => false}
938 }
939
940 it do
941 should contain_file('/etc/logrotate.d/test') \
942 .with_content(/^ noshred$/)
943 end
944 end
945
946 context 'and shred => foo' do
947 let(:params) {
948 {:path => '/var/log/foo.log', :shred => 'foo'}
949 }
950
951 it do
952 expect {
953 should contain_file('/etc/logrotate.d/test')
954 }.to raise_error(Puppet::Error, /shred must be a boolean/)
955 end
956 end
957
958 ###########################################################################
959 # START
960 context 'and start => 0' do
961 let(:params) {
962 {:path => '/var/log/foo.log', :start => 0}
963 }
964
965 it do
966 should contain_file('/etc/logrotate.d/test') \
967 .with_content(/^ start 0$/)
968 end
969 end
970
971 context 'and start => foo' do
972 let(:params) {
973 {:path => '/var/log/foo.log', :start => 'foo'}
974 }
975
976 it do
977 expect {
978 should contain_file('/etc/logrotate.d/test')
979 }.to raise_error(Puppet::Error, /start must be an integer/)
980 end
981 end
982
983 ###########################################################################
984 # UNCOMPRESSCMD
985 context 'and uncompresscmd => bunzip2' do
986 let(:params) {
987 {:path => '/var/log/foo.log', :uncompresscmd => 'bunzip2'}
988 }
989
990 it do
991 should contain_file('/etc/logrotate.d/test') \
992 .with_content(/^ uncompresscmd bunzip2$/)
993 end
994 end
995 end
996
997 context 'with a non-alphanumeric title' do
998 let(:title) { 'foo bar' }
999 let(:params) {
1000 {:path => '/var/log/foo.log'}
1001 }
1002
1003 it do
1004 expect {
1005 should contain_file('/etc/logrotate.d/foo bar')
1006 }.to raise_error(Puppet::Error, /namevar must be alphanumeric/)
1007 end
1008 end
1009 end