puppet 3.7.5-x86-mingw32 → 3.8.1-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of puppet might be problematic. Click here for more details.

Files changed (108) hide show
  1. checksums.yaml +4 -4
  2. data/ext/build_defaults.yaml +5 -5
  3. data/lib/hiera/puppet_function.rb +15 -4
  4. data/lib/puppet.rb +5 -2
  5. data/lib/puppet/application/agent.rb +5 -0
  6. data/lib/puppet/application/apply.rb +5 -0
  7. data/lib/puppet/application/device.rb +8 -3
  8. data/lib/puppet/application/master.rb +5 -0
  9. data/lib/puppet/defaults.rb +8 -0
  10. data/lib/puppet/error.rb +27 -1
  11. data/lib/puppet/file_system.rb +13 -0
  12. data/lib/puppet/file_system/file19windows.rb +8 -0
  13. data/lib/puppet/file_system/file_impl.rb +4 -0
  14. data/lib/puppet/file_system/memory_impl.rb +4 -0
  15. data/lib/puppet/functions.rb +25 -3
  16. data/lib/puppet/functions/defined.rb +130 -0
  17. data/lib/puppet/functions/hiera_include.rb +1 -1
  18. data/lib/puppet/node/environment.rb +4 -0
  19. data/lib/puppet/parser/compiler.rb +5 -2
  20. data/lib/puppet/parser/functions/defined.rb +26 -1
  21. data/lib/puppet/parser/functions/file.rb +3 -1
  22. data/lib/puppet/parser/templatewrapper.rb +2 -1
  23. data/lib/puppet/pops.rb +5 -0
  24. data/lib/puppet/pops/evaluator/access_operator.rb +25 -5
  25. data/lib/puppet/pops/evaluator/collector_transformer.rb +1 -11
  26. data/lib/puppet/pops/evaluator/compare_operator.rb +43 -0
  27. data/lib/puppet/pops/evaluator/evaluator_impl.rb +43 -28
  28. data/lib/puppet/pops/evaluator/runtime3_support.rb +9 -5
  29. data/lib/puppet/pops/functions/dispatch.rb +6 -1
  30. data/lib/puppet/pops/issue_reporter.rb +42 -16
  31. data/lib/puppet/pops/issues.rb +96 -0
  32. data/lib/puppet/pops/loader/module_loaders.rb +3 -1
  33. data/lib/puppet/pops/loaders.rb +6 -4
  34. data/lib/puppet/pops/migration/migration_checker.rb +45 -0
  35. data/lib/puppet/pops/model/factory.rb +1 -1
  36. data/lib/puppet/pops/model/model_meta.rb +1 -1
  37. data/lib/puppet/pops/parser/egrammar.ra +1 -1
  38. data/lib/puppet/pops/parser/eparser.rb +1 -1
  39. data/lib/puppet/pops/parser/epp_support.rb +18 -9
  40. data/lib/puppet/pops/parser/evaluating_parser.rb +7 -1
  41. data/lib/puppet/pops/parser/heredoc_support.rb +12 -11
  42. data/lib/puppet/pops/parser/interpolation_support.rb +7 -1
  43. data/lib/puppet/pops/parser/lexer2.rb +8 -8
  44. data/lib/puppet/pops/parser/lexer_support.rb +46 -20
  45. data/lib/puppet/pops/parser/parser_support.rb +11 -14
  46. data/lib/puppet/pops/parser/slurp_support.rb +22 -6
  47. data/lib/puppet/pops/types/type_calculator.rb +156 -55
  48. data/lib/puppet/pops/types/type_factory.rb +67 -14
  49. data/lib/puppet/pops/types/type_parser.rb +22 -13
  50. data/lib/puppet/pops/types/types.rb +21 -3
  51. data/lib/puppet/pops/types/types_meta.rb +13 -2
  52. data/lib/puppet/pops/validation.rb +25 -2
  53. data/lib/puppet/pops/validation/checker4_0.rb +25 -5
  54. data/lib/puppet/provider/group/windows_adsi.rb +18 -6
  55. data/lib/puppet/provider/mount/parsed.rb +145 -2
  56. data/lib/puppet/provider/package/pip.rb +4 -5
  57. data/lib/puppet/provider/package/zypper.rb +17 -7
  58. data/lib/puppet/provider/scheduled_task/win32_taskscheduler.rb +35 -10
  59. data/lib/puppet/provider/service/init.rb +7 -0
  60. data/lib/puppet/provider/user/windows_adsi.rb +8 -1
  61. data/lib/puppet/provider/zpool/zpool.rb +7 -2
  62. data/lib/puppet/resource.rb +1 -1
  63. data/lib/puppet/type/group.rb +1 -1
  64. data/lib/puppet/type/mount.rb +14 -3
  65. data/lib/puppet/type/scheduled_task.rb +21 -6
  66. data/lib/puppet/util/log.rb +50 -8
  67. data/lib/puppet/util/log/destinations.rb +23 -2
  68. data/lib/puppet/util/logging.rb +37 -1
  69. data/lib/puppet/util/windows/adsi.rb +36 -11
  70. data/lib/puppet/version.rb +1 -1
  71. data/spec/fixtures/unit/provider/mount/parsed/aix.filesystems +93 -85
  72. data/spec/fixtures/unit/provider/mount/parsed/aix.mount +11 -7
  73. data/spec/integration/parser/collector_spec.rb +7 -0
  74. data/spec/integration/parser/future_compiler_spec.rb +9 -0
  75. data/spec/integration/parser/resource_expressions_spec.rb +3 -0
  76. data/spec/unit/file_system_spec.rb +38 -0
  77. data/spec/unit/functions/defined_spec.rb +291 -0
  78. data/spec/unit/functions/hiera_spec.rb +8 -6
  79. data/spec/unit/functions4_spec.rb +97 -2
  80. data/spec/unit/parser/functions/file_spec.rb +8 -2
  81. data/spec/unit/parser/functions/template_spec.rb +1 -1
  82. data/spec/unit/parser/templatewrapper_spec.rb +1 -1
  83. data/spec/unit/pops/evaluator/access_ops_spec.rb +19 -0
  84. data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +61 -8
  85. data/spec/unit/pops/issues_spec.rb +16 -16
  86. data/spec/unit/pops/loaders/module_loaders_spec.rb +5 -0
  87. data/spec/unit/pops/migration_spec.rb +180 -0
  88. data/spec/unit/pops/parser/lexer2_spec.rb +152 -1
  89. data/spec/unit/pops/parser/parse_heredoc_spec.rb +26 -0
  90. data/spec/unit/pops/transformer/transform_calls_spec.rb +1 -1
  91. data/spec/unit/pops/types/type_calculator_spec.rb +204 -11
  92. data/spec/unit/pops/validation_spec.rb +66 -0
  93. data/spec/unit/provider/group/windows_adsi_spec.rb +65 -1
  94. data/spec/unit/provider/mount/parsed_spec.rb +31 -5
  95. data/spec/unit/provider/package/pip_spec.rb +19 -7
  96. data/spec/unit/provider/package/zypper_spec.rb +25 -14
  97. data/spec/unit/provider/scheduled_task/win32_taskscheduler_spec.rb +312 -70
  98. data/spec/unit/provider/service/base_spec.rb +42 -31
  99. data/spec/unit/provider/service/freebsd_spec.rb +1 -0
  100. data/spec/unit/provider/service/gentoo_spec.rb +1 -0
  101. data/spec/unit/provider/service/init_spec.rb +18 -0
  102. data/spec/unit/provider/service/openbsd_spec.rb +1 -0
  103. data/spec/unit/provider/service/redhat_spec.rb +1 -0
  104. data/spec/unit/provider/user/windows_adsi_spec.rb +21 -0
  105. data/spec/unit/provider/zpool/zpool_spec.rb +47 -10
  106. data/spec/unit/util/log_spec.rb +113 -0
  107. data/spec/unit/util/windows/adsi_spec.rb +106 -26
  108. metadata +10 -2
@@ -0,0 +1,66 @@
1
+ require 'spec_helper'
2
+ require 'puppet/pops'
3
+
4
+ describe 'Puppet::Pops::Validation::Diagnostic' do
5
+
6
+ # Mocks a SourcePosAdapter as it is used in these use cases
7
+ # of a Diagnostic
8
+ #
9
+ class MockSourcePos
10
+ attr_reader :offset
11
+ def initialize(offset)
12
+ @offset = offset
13
+ end
14
+ end
15
+
16
+ it "computes equal hash value ignoring arguments" do
17
+ issue = Puppet::Pops::Issues::DIV_BY_ZERO
18
+ source_pos = MockSourcePos.new(10)
19
+ d1 = Puppet::Pops::Validation::Diagnostic.new(:warning, issue, "foo", source_pos, {:foo => 10})
20
+ d2 = Puppet::Pops::Validation::Diagnostic.new(:warning, issue, "foo", source_pos.clone, {:bar => 20})
21
+ expect(d1.hash).to eql(d2.hash)
22
+ end
23
+
24
+ it "computes non equal hash value for different severities" do
25
+ issue = Puppet::Pops::Issues::DIV_BY_ZERO
26
+ source_pos = MockSourcePos.new(10)
27
+ d1 = Puppet::Pops::Validation::Diagnostic.new(:warning, issue, "foo", source_pos, {})
28
+ d2 = Puppet::Pops::Validation::Diagnostic.new(:error, issue, "foo", source_pos.clone, {})
29
+ expect(d1.hash).to_not eql(d2.hash)
30
+ end
31
+
32
+ it "computes non equal hash value for different offsets" do
33
+ issue = Puppet::Pops::Issues::DIV_BY_ZERO
34
+ source_pos1 = MockSourcePos.new(10)
35
+ source_pos2 = MockSourcePos.new(11)
36
+ d1 = Puppet::Pops::Validation::Diagnostic.new(:warning, issue, "foo", source_pos1, {})
37
+ d2 = Puppet::Pops::Validation::Diagnostic.new(:warning, issue, "foo", source_pos2, {})
38
+ expect(d1.hash).to_not eql(d2.hash)
39
+ end
40
+
41
+ it "can be used in a set" do
42
+ the_set = Set.new()
43
+ issue = Puppet::Pops::Issues::DIV_BY_ZERO
44
+ source_pos = MockSourcePos.new(10)
45
+ d1 = Puppet::Pops::Validation::Diagnostic.new(:warning, issue, "foo", source_pos, {})
46
+ d2 = Puppet::Pops::Validation::Diagnostic.new(:warning, issue, "foo", source_pos.clone, {})
47
+ d3 = Puppet::Pops::Validation::Diagnostic.new(:error, issue, "foo", source_pos.clone, {})
48
+ expect(the_set.add?(d1)).to_not be_nil
49
+ expect(the_set.add?(d2)).to be_nil
50
+ expect(the_set.add?(d3)).to_not be_nil
51
+ end
52
+
53
+ end
54
+
55
+ describe "Puppet::Pops::Validation::SeverityProducer" do
56
+ it 'sets default severity given in initializer' do
57
+ producer = Puppet::Pops::Validation::SeverityProducer.new(:warning)
58
+ expect(producer.severity(Puppet::Pops::Issues::DIV_BY_ZERO)).to be(:warning)
59
+ end
60
+
61
+ it 'sets default severity to :error if not given' do
62
+ producer = Puppet::Pops::Validation::SeverityProducer.new()
63
+ expect(producer.severity(Puppet::Pops::Issues::DIV_BY_ZERO)).to be(:error)
64
+ end
65
+
66
+ end
@@ -34,33 +34,77 @@ describe Puppet::Type.type(:group).provider(:windows_adsi), :if => Puppet.featur
34
34
 
35
35
  let(:user1) { stub(:account => 'user1', :domain => '.', :to_s => 'user1sid') }
36
36
  let(:user2) { stub(:account => 'user2', :domain => '.', :to_s => 'user2sid') }
37
+ let(:user3) { stub(:account => 'user3', :domain => '.', :to_s => 'user3sid') }
37
38
 
38
39
  before :each do
39
40
  Puppet::Util::Windows::SID.stubs(:name_to_sid_object).with('user1').returns(user1)
40
41
  Puppet::Util::Windows::SID.stubs(:name_to_sid_object).with('user2').returns(user2)
42
+ Puppet::Util::Windows::SID.stubs(:name_to_sid_object).with('user3').returns(user3)
41
43
  end
42
44
 
43
45
  describe "#members_insync?" do
44
46
  it "should return false when current is nil" do
45
47
  provider.members_insync?(nil, ['user2']).should be_false
46
48
  end
49
+
47
50
  it "should return false when should is nil" do
48
51
  provider.members_insync?(['user1'], nil).should be_false
49
52
  end
53
+
50
54
  it "should return false for differing lists of members" do
51
55
  provider.members_insync?(['user1'], ['user2']).should be_false
52
56
  provider.members_insync?(['user1'], []).should be_false
53
57
  provider.members_insync?([], ['user2']).should be_false
54
58
  end
59
+
55
60
  it "should return true for same lists of members" do
56
61
  provider.members_insync?(['user1', 'user2'], ['user1', 'user2']).should be_true
57
62
  end
63
+
58
64
  it "should return true for same lists of unordered members" do
59
65
  provider.members_insync?(['user1', 'user2'], ['user2', 'user1']).should be_true
60
66
  end
67
+
61
68
  it "should return true for same lists of members irrespective of duplicates" do
62
69
  provider.members_insync?(['user1', 'user2', 'user2'], ['user2', 'user1', 'user1']).should be_true
63
70
  end
71
+
72
+ it "should return true when current user(s) and should user(s) are empty lists" do
73
+ provider.members_insync?([], []).should be_true
74
+ end
75
+
76
+ context "when auth_membership => true" do
77
+ before :each do
78
+ # this is also the default
79
+ resource[:auth_membership] = true
80
+ end
81
+
82
+ it "should return false when should user(s) are not the only items in the current" do
83
+ provider.members_insync?(['user1', 'user2'], ['user1']).should be_false
84
+ end
85
+
86
+ it "should return false when current user(s) is not empty and should is an empty list" do
87
+ provider.members_insync?(['user1','user2'], []).should be_false
88
+ end
89
+ end
90
+
91
+ context "when auth_membership => false" do
92
+ before :each do
93
+ resource[:auth_membership] = false
94
+ end
95
+
96
+ it "should return true when current user(s) contains at least the should list" do
97
+ provider.members_insync?(['user1','user2'], ['user1']).should be_true
98
+ end
99
+
100
+ it "should return true when current user(s) is not empty and should is an empty list" do
101
+ provider.members_insync?(['user1','user2'], []).should be_true
102
+ end
103
+
104
+ it "should return true when current user(s) contains at least the should list, even unordered" do
105
+ provider.members_insync?(['user3','user1','user2'], ['user2','user1']).should be_true
106
+ end
107
+ end
64
108
  end
65
109
 
66
110
  describe "#members_to_s" do
@@ -119,7 +163,7 @@ describe Puppet::Type.type(:group).provider(:windows_adsi), :if => Puppet.featur
119
163
 
120
164
  create = sequence('create')
121
165
  group.expects(:commit).in_sequence(create)
122
- group.expects(:set_members).with(['user1', 'user2']).in_sequence(create)
166
+ group.expects(:set_members).with(['user1', 'user2'], true).in_sequence(create)
123
167
 
124
168
  provider.create
125
169
  end
@@ -130,6 +174,18 @@ describe Puppet::Type.type(:group).provider(:windows_adsi), :if => Puppet.featur
130
174
  /Cannot create group if user 'testers' exists./ )
131
175
  end
132
176
 
177
+ it "should fail with an actionable message when trying to create an active directory group" do
178
+ resource[:name] = 'DOMAIN\testdomaingroup'
179
+ Puppet::Util::Windows::ADSI::User.expects(:exists?).with(resource[:name]).returns(false)
180
+ connection.expects(:Create)
181
+ connection.expects(:SetInfo).raises( WIN32OLERuntimeError.new("(in OLE method `SetInfo': )\n OLE error code:8007089A in Active Directory\n The specified username is invalid.\r\n\n HRESULT error code:0x80020009\n Exception occurred."))
182
+
183
+ expect{ provider.create }.to raise_error(
184
+ Puppet::Error,
185
+ /not able to create\/delete domain groups/
186
+ )
187
+ end
188
+
133
189
  it 'should commit a newly created group' do
134
190
  provider.group.expects( :commit )
135
191
 
@@ -152,6 +208,14 @@ describe Puppet::Type.type(:group).provider(:windows_adsi), :if => Puppet.featur
152
208
  provider.delete
153
209
  end
154
210
 
211
+ it 'should not run commit on a deleted group' do
212
+ connection.expects(:Delete).with('group', 'testers')
213
+ connection.expects(:SetInfo).never
214
+
215
+ provider.delete
216
+ provider.flush
217
+ end
218
+
155
219
  it "should report the group's SID as gid" do
156
220
  Puppet::Util::Windows::SID.expects(:name_to_sid).with('testers').returns('S-1-5-32-547')
157
221
  provider.gid.should == 'S-1-5-32-547'
@@ -3,6 +3,9 @@ require 'spec_helper'
3
3
  require 'shared_behaviours/all_parsedfile_providers'
4
4
 
5
5
  describe Puppet::Type.type(:mount).provider(:parsed), :unless => Puppet.features.microsoft_windows? do
6
+ before :each do
7
+ Facter.clear
8
+ end
6
9
 
7
10
  let :vfstab_sample do
8
11
  "/dev/dsk/c0d0s0 /dev/rdsk/c0d0s0 \t\t / \t ufs 1 no\t-"
@@ -18,6 +21,11 @@ describe Puppet::Type.type(:mount).provider(:parsed), :unless => Puppet.features
18
21
  described_class.default_target.should == '/etc/vfstab'
19
22
  end
20
23
 
24
+ it "should default to /etc/vfstab on Solaris" do
25
+ pending "This test only works on AIX" unless Facter.value(:osfamily) == 'AIX'
26
+ described_class.default_target.should == '/etc/filesystems'
27
+ end
28
+
21
29
  it "should default to /etc/fstab on anything else" do
22
30
  pending "This test does not work on Solaris" if Facter.value(:osfamily) == 'Solaris'
23
31
  described_class.default_target.should == '/etc/fstab'
@@ -160,10 +168,14 @@ FSTAB
160
168
  described_class.stubs(:mountcmd).returns(File.read(my_fixture('aix.mount')))
161
169
  mounts = described_class.mountinstances
162
170
  mounts[0].should == { :name => '/', :mounted => :yes }
163
- mounts[1].should == { :name => '/tmp', :mounted => :yes }
164
- mounts[2].should == { :name => '/home', :mounted => :yes }
165
- mounts[3].should == { :name => '/usr', :mounted => :yes }
166
- mounts[4].should == { :name => '/usr/code', :mounted => :yes }
171
+ mounts[1].should == { :name => '/usr', :mounted => :yes }
172
+ mounts[2].should == { :name => '/var', :mounted => :yes }
173
+ mounts[3].should == { :name => '/tmp', :mounted => :yes }
174
+ mounts[4].should == { :name => '/home', :mounted => :yes }
175
+ mounts[5].should == { :name => '/admin', :mounted => :yes }
176
+ mounts[6].should == { :name => '/proc', :mounted => :yes }
177
+ mounts[7].should == { :name => '/opt', :mounted => :yes }
178
+ mounts[8].should == { :name => '/srv/aix', :mounted => :yes }
167
179
  end
168
180
 
169
181
  it "should raise an error if a line is not understandable" do
@@ -173,7 +185,21 @@ FSTAB
173
185
 
174
186
  end
175
187
 
176
- it "should support AIX's paragraph based /etc/filesystems"
188
+ it "should support AIX's paragraph based /etc/filesystems" do
189
+ pending "This test only works on AIX" unless Facter.value(:osfamily) == 'AIX'
190
+ Facter.stubs(:value).with(:osfamily).returns 'AIX'
191
+ described_class.stubs(:default_target).returns my_fixture('aix.filesystems')
192
+ described_class.stubs(:mountcmd).returns File.read(my_fixture('aix.mount'))
193
+ instances = described_class.instances
194
+ instances[0].name.should == "/"
195
+ instances[0].device.should == "/dev/hd4"
196
+ instances[0].fstype.should == "jfs2"
197
+ instances[0].options.should == "check=false,free=true,log=NULL,mount=automatic,quota=no,type=bootfs,vol=root"
198
+ instances[11].name.should == "/srv/aix"
199
+ instances[11].device.should == "mynode"
200
+ instances[11].fstype.should == "nfs"
201
+ instances[11].options.should == "vers=2,account=false,log=NULL,mount=true"
202
+ end
177
203
 
178
204
  my_fixtures('*.fstab').each do |fstab|
179
205
  platform = File.basename(fstab, '.fstab')
@@ -2,7 +2,7 @@
2
2
  require 'spec_helper'
3
3
 
4
4
  provider_class = Puppet::Type.type(:package).provider(:pip)
5
- osfamilies = { 'RedHat' => 'pip-python', 'Not RedHat' => 'pip' }
5
+ osfamilies = { ['RedHat', '6'] => 'pip-python', ['RedHat', '7'] => 'pip', ['Not RedHat', nil] => 'pip' }
6
6
 
7
7
  describe provider_class do
8
8
 
@@ -32,11 +32,18 @@ describe provider_class do
32
32
  end
33
33
 
34
34
  describe "cmd" do
35
- it "should return pip-python on RedHat systems" do
35
+ it "should return pip-python on RedHat < 7 systems" do
36
36
  Facter.stubs(:value).with(:osfamily).returns("RedHat")
37
+ Facter.stubs(:value).with(:operatingsystemmajrelease).returns("6")
37
38
  provider_class.cmd.should == 'pip-python'
38
39
  end
39
40
 
41
+ it "should return pip on RedHat >= 7 systems" do
42
+ Facter.stubs(:value).with(:osfamily).returns("RedHat")
43
+ Facter.stubs(:value).with(:operatingsystemmajrelease).returns("7")
44
+ provider_class.cmd.should == 'pip'
45
+ end
46
+
40
47
  it "should return pip by default" do
41
48
  Facter.stubs(:value).with(:osfamily).returns("Not RedHat")
42
49
  provider_class.cmd.should == 'pip'
@@ -48,7 +55,8 @@ describe provider_class do
48
55
 
49
56
  osfamilies.each do |osfamily, pip_cmd|
50
57
  it "should return an array on #{osfamily} when #{pip_cmd} is present" do
51
- Facter.stubs(:value).with(:osfamily).returns(osfamily)
58
+ Facter.stubs(:value).with(:osfamily).returns(osfamily.first)
59
+ Facter.stubs(:value).with(:operatingsystemmajrelease).returns(osfamily.last)
52
60
  provider_class.expects(:which).with(pip_cmd).returns("/fake/bin/pip")
53
61
  p = stub("process")
54
62
  p.expects(:collect).yields("real_package==1.2.5")
@@ -57,7 +65,8 @@ describe provider_class do
57
65
  end
58
66
 
59
67
  it "should return an empty array on #{osfamily} when #{pip_cmd} is missing" do
60
- Facter.stubs(:value).with(:osfamily).returns(osfamily)
68
+ Facter.stubs(:value).with(:osfamily).returns(osfamily.first)
69
+ Facter.stubs(:value).with(:operatingsystemmajrelease).returns(osfamily.last)
61
70
  provider_class.expects(:which).with(pip_cmd).returns nil
62
71
  provider_class.instances.should == []
63
72
  end
@@ -219,21 +228,24 @@ describe provider_class do
219
228
 
220
229
  osfamilies.each do |osfamily, pip_cmd|
221
230
  it "should retry on #{osfamily} if #{pip_cmd} has not yet been found" do
222
- Facter.stubs(:value).with(:osfamily).returns(osfamily)
231
+ Facter.stubs(:value).with(:osfamily).returns(osfamily.first)
232
+ Facter.stubs(:value).with(:operatingsystemmajrelease).returns(osfamily.last)
223
233
  @provider.expects(:pip).twice.with('freeze').raises(NoMethodError).then.returns(nil)
224
234
  @provider.expects(:which).with(pip_cmd).returns("/fake/bin/pip")
225
235
  @provider.method(:lazy_pip).call "freeze"
226
236
  end
227
237
 
228
238
  it "should fail on #{osfamily} if #{pip_cmd} is missing" do
229
- Facter.stubs(:value).with(:osfamily).returns(osfamily)
239
+ Facter.stubs(:value).with(:osfamily).returns(osfamily.first)
240
+ Facter.stubs(:value).with(:operatingsystemmajrelease).returns(osfamily.last)
230
241
  @provider.expects(:pip).with('freeze').raises(NoMethodError)
231
242
  @provider.expects(:which).with(pip_cmd).returns(nil)
232
243
  expect { @provider.method(:lazy_pip).call("freeze") }.to raise_error(NoMethodError)
233
244
  end
234
245
 
235
246
  it "should output a useful error message on #{osfamily} if #{pip_cmd} is missing" do
236
- Facter.stubs(:value).with(:osfamily).returns(osfamily)
247
+ Facter.stubs(:value).with(:osfamily).returns(osfamily.first)
248
+ Facter.stubs(:value).with(:operatingsystemmajrelease).returns(osfamily.last)
237
249
  @provider.expects(:pip).with('freeze').raises(NoMethodError)
238
250
  @provider.expects(:which).with(pip_cmd).returns(nil)
239
251
  expect { @provider.method(:lazy_pip).call("freeze") }.
@@ -80,7 +80,7 @@ describe provider_class do
80
80
  @resource.stubs(:should).with(:ensure).returns :latest
81
81
  @resource.stubs(:allow_virtual?).returns false
82
82
  @provider.stubs(:zypper_version).returns "0.6.104"
83
- @provider.expects(:zypper).with('--terse', :install, '--auto-agree-with-licenses', '--no-confirm', '--name', 'mypackage')
83
+ @provider.expects(:zypper).with('--terse', :install, '--auto-agree-with-licenses', '--no-confirm', 'mypackage')
84
84
  @provider.expects(:query).returns "mypackage 0 1.2.3 4.5.6 x86_64"
85
85
  @provider.install
86
86
  end
@@ -101,7 +101,7 @@ describe provider_class do
101
101
  @resource.stubs(:should).with(:ensure).returns :latest
102
102
  @resource.stubs(:allow_virtual?).returns false
103
103
  @provider.stubs(:zypper_version).returns "0.6.13"
104
- @provider.expects(:zypper).with('--terse', :install, '--no-confirm', '--name', 'mypackage')
104
+ @provider.expects(:zypper).with('--terse', :install, '--no-confirm', 'mypackage')
105
105
  @provider.expects(:query).returns "mypackage 0 1.2.3 4.5.6 x86_64"
106
106
  @provider.install
107
107
  end
@@ -124,13 +124,24 @@ describe provider_class do
124
124
  end
125
125
  end
126
126
 
127
- it "should install a virtual package" do
128
- @resource.stubs(:should).with(:ensure).returns :installed
129
- @resource.stubs(:allow_virtual?).returns true
130
- @provider.stubs(:zypper_version).returns "0.6.13"
131
- @provider.expects(:zypper).with('--terse', :install, '--no-confirm', 'mypackage')
132
- @provider.expects(:query).returns "mypackage 0 1.2.3 4.5.6 x86_64"
133
- @provider.install
127
+ describe "should install a virtual package" do
128
+ it "when zypper version = 0.6.13" do
129
+ @resource.stubs(:should).with(:ensure).returns :installed
130
+ @resource.stubs(:allow_virtual?).returns true
131
+ @provider.stubs(:zypper_version).returns "0.6.13"
132
+ @provider.expects(:zypper).with('--terse', :install, '--no-confirm', 'mypackage')
133
+ @provider.expects(:query).returns "mypackage 0 1.2.3 4.5.6 x86_64"
134
+ @provider.install
135
+ end
136
+
137
+ it "when zypper version >= 1.0.0" do
138
+ @resource.stubs(:should).with(:ensure).returns :installed
139
+ @resource.stubs(:allow_virtual?).returns true
140
+ @provider.stubs(:zypper_version).returns "1.2.8"
141
+ @provider.expects(:zypper).with('--quiet', :install, '--auto-agree-with-licenses', '--no-confirm', 'mypackage')
142
+ @provider.expects(:query).returns "mypackage 0 1.2.3 4.5.6 x86_64"
143
+ @provider.install
144
+ end
134
145
  end
135
146
 
136
147
  describe "when installing with zypper install options" do
@@ -141,8 +152,8 @@ describe provider_class do
141
152
  @resource.stubs(:allow_virtual?).returns false
142
153
  @provider.stubs(:zypper_version).returns "1.2.8"
143
154
 
144
- @provider.expects(:zypper).with('--quiet', :install,
145
- '--auto-agree-with-licenses', '--no-confirm', '--no-gpg-check', '-p=/vagrant/files/localrepo/', 'php5-5.4.10-4.5.6')
155
+ @provider.expects(:zypper).with('--quiet', '--no-gpg-check', :install,
156
+ '--auto-agree-with-licenses', '--no-confirm', '-p=/vagrant/files/localrepo/', 'php5-5.4.10-4.5.6')
146
157
  @provider.expects(:query).returns "php5 0 5.4.10 4.5.6 x86_64"
147
158
  @provider.install
148
159
  end
@@ -154,7 +165,7 @@ describe provider_class do
154
165
  @resource.stubs(:allow_virtual?).returns false
155
166
 
156
167
  @provider.stubs(:zypper_version).returns '1.2.8'
157
- @provider.expects(:zypper).with('--quiet', :install, '--auto-agree-with-licenses', '--no-confirm', '--name', '--a=foo', '--b="quoted bar"', 'vim')
168
+ @provider.expects(:zypper).with('--quiet', :install, '--auto-agree-with-licenses', '--no-confirm', '--a=foo', '--b="quoted bar"', '--name', 'vim')
158
169
  @provider.expects(:query).returns 'package vim is not installed'
159
170
  @provider.install
160
171
  end
@@ -166,7 +177,7 @@ describe provider_class do
166
177
  @resource.stubs(:allow_virtual?).returns false
167
178
 
168
179
  @provider.stubs(:zypper_version).returns '1.2.8'
169
- @provider.expects(:zypper).with('--quiet', :install, '--auto-agree-with-licenses', '--no-confirm', '--name', '--a', '--b', '--c', 'vim')
180
+ @provider.expects(:zypper).with('--quiet', :install, '--auto-agree-with-licenses', '--no-confirm', '--a', '--b', '--c', '--name', 'vim')
170
181
  @provider.expects(:query).returns 'package vim is not installed'
171
182
  @provider.install
172
183
  end
@@ -178,7 +189,7 @@ describe provider_class do
178
189
  @resource.stubs(:allow_virtual?).returns false
179
190
 
180
191
  @provider.stubs(:zypper_version).returns '1.2.8'
181
- @provider.expects(:zypper).with('--quiet', :install, '--auto-agree-with-licenses', '--no-confirm', '--name', '--a --b --c', 'vim')
192
+ @provider.expects(:zypper).with('--quiet', :install, '--auto-agree-with-licenses', '--no-confirm', '--a --b --c', '--name', 'vim')
182
193
  @provider.expects(:query).returns 'package vim is not installed'
183
194
  @provider.install
184
195
  end
@@ -143,15 +143,43 @@ describe Puppet::Type.type(:scheduled_task).provider(:win32_taskscheduler), :if
143
143
  })
144
144
 
145
145
  resource.provider.trigger.should == [{
146
- 'start_date' => '2011-9-12',
147
- 'start_time' => '13:20',
148
- 'schedule' => 'daily',
149
- 'every' => '2',
150
- 'enabled' => true,
151
- 'index' => 0,
146
+ 'start_date' => '2011-9-12',
147
+ 'start_time' => '13:20',
148
+ 'schedule' => 'daily',
149
+ 'every' => '2',
150
+ 'minutes_interval' => 0,
151
+ 'minutes_duration' => 0,
152
+ 'enabled' => true,
153
+ 'index' => 0,
152
154
  }]
153
155
  end
154
156
 
157
+ it 'should handle a single daily with repeat trigger' do
158
+ @mock_task.expects(:trigger).with(0).returns({
159
+ 'trigger_type' => Win32::TaskScheduler::TASK_TIME_TRIGGER_DAILY,
160
+ 'start_year' => 2011,
161
+ 'start_month' => 9,
162
+ 'start_day' => 12,
163
+ 'start_hour' => 13,
164
+ 'start_minute' => 20,
165
+ 'minutes_interval' => 60,
166
+ 'minutes_duration' => 180,
167
+ 'flags' => 0,
168
+ 'type' => { 'days_interval' => 2 },
169
+ })
170
+
171
+ expect(resource.provider.trigger).to eq([{
172
+ 'start_date' => '2011-9-12',
173
+ 'start_time' => '13:20',
174
+ 'schedule' => 'daily',
175
+ 'every' => '2',
176
+ 'minutes_interval' => 60,
177
+ 'minutes_duration' => 180,
178
+ 'enabled' => true,
179
+ 'index' => 0,
180
+ }])
181
+ end
182
+
155
183
  it 'should handle a single weekly trigger' do
156
184
  scheduled_days_of_week = Win32::TaskScheduler::MONDAY |
157
185
  Win32::TaskScheduler::WEDNESDAY |
@@ -172,13 +200,15 @@ describe Puppet::Type.type(:scheduled_task).provider(:win32_taskscheduler), :if
172
200
  })
173
201
 
174
202
  resource.provider.trigger.should == [{
175
- 'start_date' => '2011-9-12',
176
- 'start_time' => '13:20',
177
- 'schedule' => 'weekly',
178
- 'every' => '2',
179
- 'on' => ['sun', 'mon', 'wed', 'fri'],
180
- 'enabled' => true,
181
- 'index' => 0,
203
+ 'start_date' => '2011-9-12',
204
+ 'start_time' => '13:20',
205
+ 'schedule' => 'weekly',
206
+ 'every' => '2',
207
+ 'day_of_week' => ['sun', 'mon', 'wed', 'fri'],
208
+ 'minutes_interval' => 0,
209
+ 'minutes_duration' => 0,
210
+ 'enabled' => true,
211
+ 'index' => 0,
182
212
  }]
183
213
  end
184
214
 
@@ -205,13 +235,15 @@ describe Puppet::Type.type(:scheduled_task).provider(:win32_taskscheduler), :if
205
235
  })
206
236
 
207
237
  resource.provider.trigger.should == [{
208
- 'start_date' => '2011-9-12',
209
- 'start_time' => '13:20',
210
- 'schedule' => 'monthly',
211
- 'months' => [1, 2, 8, 9, 12],
212
- 'on' => [1, 3, 5, 15, 'last'],
213
- 'enabled' => true,
214
- 'index' => 0,
238
+ 'start_date' => '2011-9-12',
239
+ 'start_time' => '13:20',
240
+ 'schedule' => 'monthly',
241
+ 'months' => [1, 2, 8, 9, 12],
242
+ 'on' => [1, 3, 5, 15, 'last'],
243
+ 'minutes_interval' => 0,
244
+ 'minutes_duration' => 0,
245
+ 'enabled' => true,
246
+ 'index' => 0,
215
247
  }]
216
248
  end
217
249
 
@@ -247,6 +279,8 @@ describe Puppet::Type.type(:scheduled_task).provider(:win32_taskscheduler), :if
247
279
  'months' => [1, 2, 8, 9, 12],
248
280
  'which_occurrence' => 'first',
249
281
  'day_of_week' => ['sun', 'mon', 'wed', 'fri'],
282
+ 'minutes_interval' => 0,
283
+ 'minutes_duration' => 0,
250
284
  'enabled' => true,
251
285
  'index' => 0,
252
286
  }]
@@ -264,11 +298,13 @@ describe Puppet::Type.type(:scheduled_task).provider(:win32_taskscheduler), :if
264
298
  })
265
299
 
266
300
  resource.provider.trigger.should == [{
267
- 'start_date' => '2011-9-12',
268
- 'start_time' => '13:20',
269
- 'schedule' => 'once',
270
- 'enabled' => true,
271
- 'index' => 0,
301
+ 'start_date' => '2011-9-12',
302
+ 'start_time' => '13:20',
303
+ 'schedule' => 'once',
304
+ 'minutes_interval' => 0,
305
+ 'minutes_duration' => 0,
306
+ 'enabled' => true,
307
+ 'index' => 0,
272
308
  }]
273
309
  end
274
310
  end
@@ -305,29 +341,102 @@ describe Puppet::Type.type(:scheduled_task).provider(:win32_taskscheduler), :if
305
341
 
306
342
  resource.provider.trigger.should =~ [
307
343
  {
308
- 'start_date' => '2011-10-13',
309
- 'start_time' => '14:21',
310
- 'schedule' => 'once',
311
- 'enabled' => true,
312
- 'index' => 0,
344
+ 'start_date' => '2011-10-13',
345
+ 'start_time' => '14:21',
346
+ 'schedule' => 'once',
347
+ 'minutes_interval' => 0,
348
+ 'minutes_duration' => 0,
349
+ 'enabled' => true,
350
+ 'index' => 0,
313
351
  },
314
352
  {
315
- 'start_date' => '2012-11-14',
316
- 'start_time' => '15:22',
317
- 'schedule' => 'once',
318
- 'enabled' => true,
319
- 'index' => 1,
353
+ 'start_date' => '2012-11-14',
354
+ 'start_time' => '15:22',
355
+ 'schedule' => 'once',
356
+ 'minutes_interval' => 0,
357
+ 'minutes_duration' => 0,
358
+ 'enabled' => true,
359
+ 'index' => 1,
320
360
  },
321
361
  {
322
- 'start_date' => '2013-12-15',
323
- 'start_time' => '16:23',
324
- 'schedule' => 'once',
325
- 'enabled' => true,
326
- 'index' => 2,
362
+ 'start_date' => '2013-12-15',
363
+ 'start_time' => '16:23',
364
+ 'schedule' => 'once',
365
+ 'minutes_interval' => 0,
366
+ 'minutes_duration' => 0,
367
+ 'enabled' => true,
368
+ 'index' => 2,
327
369
  }
328
370
  ]
329
371
  end
330
372
 
373
+ it 'should handle multiple triggers with repeat triggers' do
374
+ @mock_task.expects(:trigger_count).returns(3)
375
+ @mock_task.expects(:trigger).with(0).returns({
376
+ 'trigger_type' => Win32::TaskScheduler::TASK_TIME_TRIGGER_ONCE,
377
+ 'start_year' => 2011,
378
+ 'start_month' => 10,
379
+ 'start_day' => 13,
380
+ 'start_hour' => 14,
381
+ 'start_minute' => 21,
382
+ 'minutes_interval' => 15,
383
+ 'minutes_duration' => 60,
384
+ 'flags' => 0,
385
+ })
386
+ @mock_task.expects(:trigger).with(1).returns({
387
+ 'trigger_type' => Win32::TaskScheduler::TASK_TIME_TRIGGER_ONCE,
388
+ 'start_year' => 2012,
389
+ 'start_month' => 11,
390
+ 'start_day' => 14,
391
+ 'start_hour' => 15,
392
+ 'start_minute' => 22,
393
+ 'minutes_interval' => 30,
394
+ 'minutes_duration' => 120,
395
+ 'flags' => 0,
396
+ })
397
+ @mock_task.expects(:trigger).with(2).returns({
398
+ 'trigger_type' => Win32::TaskScheduler::TASK_TIME_TRIGGER_ONCE,
399
+ 'start_year' => 2013,
400
+ 'start_month' => 12,
401
+ 'start_day' => 15,
402
+ 'start_hour' => 16,
403
+ 'start_minute' => 23,
404
+ 'minutes_interval' => 60,
405
+ 'minutes_duration' => 240,
406
+ 'flags' => 0,
407
+ })
408
+
409
+ expect(resource.provider.trigger).to match_array([
410
+ {
411
+ 'start_date' => '2011-10-13',
412
+ 'start_time' => '14:21',
413
+ 'schedule' => 'once',
414
+ 'minutes_interval' => 15,
415
+ 'minutes_duration' => 60,
416
+ 'enabled' => true,
417
+ 'index' => 0,
418
+ },
419
+ {
420
+ 'start_date' => '2012-11-14',
421
+ 'start_time' => '15:22',
422
+ 'schedule' => 'once',
423
+ 'minutes_interval' => 30,
424
+ 'minutes_duration' => 120,
425
+ 'enabled' => true,
426
+ 'index' => 1,
427
+ },
428
+ {
429
+ 'start_date' => '2013-12-15',
430
+ 'start_time' => '16:23',
431
+ 'schedule' => 'once',
432
+ 'minutes_interval' => 60,
433
+ 'minutes_duration' => 240,
434
+ 'enabled' => true,
435
+ 'index' => 2,
436
+ }
437
+ ])
438
+ end
439
+
331
440
  it 'should skip triggers Win32::TaskScheduler cannot handle' do
332
441
  @mock_task.expects(:trigger_count).returns(3)
333
442
  @mock_task.expects(:trigger).with(0).returns({
@@ -354,18 +463,22 @@ describe Puppet::Type.type(:scheduled_task).provider(:win32_taskscheduler), :if
354
463
 
355
464
  resource.provider.trigger.should =~ [
356
465
  {
357
- 'start_date' => '2011-10-13',
358
- 'start_time' => '14:21',
359
- 'schedule' => 'once',
360
- 'enabled' => true,
361
- 'index' => 0,
466
+ 'start_date' => '2011-10-13',
467
+ 'start_time' => '14:21',
468
+ 'schedule' => 'once',
469
+ 'minutes_interval' => 0,
470
+ 'minutes_duration' => 0,
471
+ 'enabled' => true,
472
+ 'index' => 0,
362
473
  },
363
474
  {
364
- 'start_date' => '2013-12-15',
365
- 'start_time' => '16:23',
366
- 'schedule' => 'once',
367
- 'enabled' => true,
368
- 'index' => 2,
475
+ 'start_date' => '2013-12-15',
476
+ 'start_time' => '16:23',
477
+ 'schedule' => 'once',
478
+ 'minutes_interval' => 0,
479
+ 'minutes_duration' => 0,
480
+ 'enabled' => true,
481
+ 'index' => 2,
369
482
  }
370
483
  ]
371
484
  end
@@ -396,18 +509,22 @@ describe Puppet::Type.type(:scheduled_task).provider(:win32_taskscheduler), :if
396
509
 
397
510
  resource.provider.trigger.should =~ [
398
511
  {
399
- 'start_date' => '2011-10-13',
400
- 'start_time' => '14:21',
401
- 'schedule' => 'once',
402
- 'enabled' => true,
403
- 'index' => 0,
512
+ 'start_date' => '2011-10-13',
513
+ 'start_time' => '14:21',
514
+ 'schedule' => 'once',
515
+ 'minutes_interval' => 0,
516
+ 'minutes_duration' => 0,
517
+ 'enabled' => true,
518
+ 'index' => 0,
404
519
  },
405
520
  {
406
- 'start_date' => '2013-12-15',
407
- 'start_time' => '16:23',
408
- 'schedule' => 'once',
409
- 'enabled' => true,
410
- 'index' => 2,
521
+ 'start_date' => '2013-12-15',
522
+ 'start_time' => '16:23',
523
+ 'schedule' => 'once',
524
+ 'minutes_interval' => 0,
525
+ 'minutes_duration' => 0,
526
+ 'enabled' => true,
527
+ 'index' => 2,
411
528
  }
412
529
  ]
413
530
  end
@@ -529,11 +646,13 @@ describe Puppet::Type.type(:scheduled_task).provider(:win32_taskscheduler), :if
529
646
  })
530
647
 
531
648
  mock_task_trigger = {
532
- 'start_date' => '2011-10-13',
533
- 'start_time' => '14:21',
534
- 'schedule' => 'once',
535
- 'enabled' => true,
536
- 'index' => 0,
649
+ 'start_date' => '2011-10-13',
650
+ 'start_time' => '14:21',
651
+ 'schedule' => 'once',
652
+ 'minutes_interval' => 0,
653
+ 'minutes_duration' => 0,
654
+ 'enabled' => true,
655
+ 'index' => 0,
537
656
  }
538
657
 
539
658
  resource.provider.trigger.should == [mock_task_trigger]
@@ -542,11 +661,13 @@ describe Puppet::Type.type(:scheduled_task).provider(:win32_taskscheduler), :if
542
661
  resource.provider.clear_task
543
662
 
544
663
  resource.provider.trigger.should == [{
545
- 'start_date' => '2012-11-14',
546
- 'start_time' => '15:22',
547
- 'schedule' => 'once',
548
- 'enabled' => true,
549
- 'index' => 0,
664
+ 'start_date' => '2012-11-14',
665
+ 'start_time' => '15:22',
666
+ 'schedule' => 'once',
667
+ 'minutes_interval' => 0,
668
+ 'minutes_duration' => 0,
669
+ 'enabled' => true,
670
+ 'index' => 0,
550
671
  }]
551
672
  end
552
673
  end
@@ -1045,6 +1166,127 @@ describe Puppet::Type.type(:scheduled_task).provider(:win32_taskscheduler), :if
1045
1166
  let(:provider) { described_class.new(:name => 'Test Task', :command => 'C:\Windows\System32\notepad.exe') }
1046
1167
  let(:trigger) { provider.translate_hash_to_trigger(@puppet_trigger) }
1047
1168
 
1169
+ context "working with repeat every x triggers" do
1170
+ before :each do
1171
+ @puppet_trigger['schedule'] = 'once'
1172
+ end
1173
+
1174
+ it 'should succeed if minutes_interval is equal to 0' do
1175
+ @puppet_trigger['minutes_interval'] = '0'
1176
+
1177
+ expect(trigger['minutes_interval']).to eq(0)
1178
+ end
1179
+
1180
+ it 'should default minutes_duration to a full day when minutes_interval is greater than 0 without setting minutes_duration' do
1181
+ @puppet_trigger['minutes_interval'] = '1'
1182
+
1183
+ expect(trigger['minutes_duration']).to eq(1440)
1184
+ end
1185
+
1186
+ it 'should succeed if minutes_interval is greater than 0 and minutes_duration is also set' do
1187
+ @puppet_trigger['minutes_interval'] = '1'
1188
+ @puppet_trigger['minutes_duration'] = '2'
1189
+
1190
+ expect(trigger['minutes_interval']).to eq(1)
1191
+ end
1192
+
1193
+ it 'should fail if minutes_interval is less than 0' do
1194
+ @puppet_trigger['minutes_interval'] = '-1'
1195
+
1196
+ expect { trigger }.to raise_error(
1197
+ Puppet::Error,
1198
+ 'minutes_interval must be an integer greater or equal to 0'
1199
+ )
1200
+ end
1201
+
1202
+ it 'should fail if minutes_interval is not an integer' do
1203
+ @puppet_trigger['minutes_interval'] = 'abc'
1204
+ expect { trigger }.to raise_error(ArgumentError)
1205
+ end
1206
+
1207
+ it 'should succeed if minutes_duration is equal to 0' do
1208
+ @puppet_trigger['minutes_duration'] = '0'
1209
+ expect(trigger['minutes_duration']).to eq(0)
1210
+ end
1211
+
1212
+ it 'should succeed if minutes_duration is greater than 0' do
1213
+ @puppet_trigger['minutes_duration'] = '1'
1214
+ expect(trigger['minutes_duration']).to eq(1)
1215
+ end
1216
+
1217
+ it 'should fail if minutes_duration is less than 0' do
1218
+ @puppet_trigger['minutes_duration'] = '-1'
1219
+
1220
+ expect { trigger }.to raise_error(
1221
+ Puppet::Error,
1222
+ 'minutes_duration must be an integer greater than minutes_interval and equal to or greater than 0'
1223
+ )
1224
+ end
1225
+
1226
+ it 'should fail if minutes_duration is not an integer' do
1227
+ @puppet_trigger['minutes_duration'] = 'abc'
1228
+ expect { trigger }.to raise_error(ArgumentError)
1229
+ end
1230
+
1231
+ it 'should succeed if minutes_duration is equal to a full day' do
1232
+ @puppet_trigger['minutes_duration'] = '1440'
1233
+ expect(trigger['minutes_duration']).to eq(1440)
1234
+ end
1235
+
1236
+ it 'should succeed if minutes_duration is equal to three days' do
1237
+ @puppet_trigger['minutes_duration'] = '4320'
1238
+ expect(trigger['minutes_duration']).to eq(4320)
1239
+ end
1240
+
1241
+ it 'should succeed if minutes_duration is greater than minutes_duration' do
1242
+ @puppet_trigger['minutes_interval'] = '10'
1243
+ @puppet_trigger['minutes_duration'] = '11'
1244
+
1245
+ expect(trigger['minutes_interval']).to eq(10)
1246
+ expect(trigger['minutes_duration']).to eq(11)
1247
+ end
1248
+
1249
+ it 'should fail if minutes_duration is equal to minutes_interval' do
1250
+ # On Windows 2003, the duration must be greater than the interval
1251
+ # on other platforms the values can be equal.
1252
+ @puppet_trigger['minutes_interval'] = '10'
1253
+ @puppet_trigger['minutes_duration'] = '10'
1254
+
1255
+ expect { trigger }.to raise_error(
1256
+ Puppet::Error,
1257
+ 'minutes_duration must be an integer greater than minutes_interval and equal to or greater than 0'
1258
+ )
1259
+ end
1260
+
1261
+ it 'should succeed if minutes_duration and minutes_interval are both set to 0' do
1262
+ @puppet_trigger['minutes_interval'] = '0'
1263
+ @puppet_trigger['minutes_duration'] = '0'
1264
+
1265
+ expect(trigger['minutes_interval']).to eq(0)
1266
+ expect(trigger['minutes_duration']).to eq(0)
1267
+ end
1268
+
1269
+ it 'should fail if minutes_duration is less than minutes_interval' do
1270
+ @puppet_trigger['minutes_interval'] = '10'
1271
+ @puppet_trigger['minutes_duration'] = '9'
1272
+
1273
+ expect { trigger }.to raise_error(
1274
+ Puppet::Error,
1275
+ 'minutes_duration must be an integer greater than minutes_interval and equal to or greater than 0'
1276
+ )
1277
+ end
1278
+
1279
+ it 'should fail if minutes_duration is less than minutes_interval and set to 0' do
1280
+ @puppet_trigger['minutes_interval'] = '10'
1281
+ @puppet_trigger['minutes_duration'] = '0'
1282
+
1283
+ expect { trigger }.to raise_error(
1284
+ Puppet::Error,
1285
+ 'minutes_interval cannot be set without minutes_duration also being set to a number greater than 0'
1286
+ )
1287
+ end
1288
+ end
1289
+
1048
1290
  describe 'when given a one-time trigger' do
1049
1291
  before :each do
1050
1292
  @puppet_trigger['schedule'] = 'once'