Skip to content

Commit 4a5da6a

Browse files
committed
Merge pull request #130 from lucywyman/MODULES-2706-types-and-providers
(MODULES-2706) types and providers
2 parents b2830e7 + 8c5882e commit 4a5da6a

File tree

4 files changed

+518
-4
lines changed

4 files changed

+518
-4
lines changed

lib/puppet/type/logical_volume.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def insync?(is)
9999
newparam(:stripes) do
100100
desc "The number of stripes to allocate for the new logical volume."
101101
validate do |value|
102-
unless value =~ /^[0-9]+/i
102+
unless value.to_s =~ /^[0-9]+$/i
103103
raise ArgumentError , "#{value} is not a valid stripe count"
104104
end
105105
end
@@ -108,7 +108,7 @@ def insync?(is)
108108
newparam(:stripesize) do
109109
desc "The stripesize to use for the new logical volume."
110110
validate do |value|
111-
unless value =~ /^[0-9]+/i
111+
unless value.to_s =~ /^[0-9]+$/i
112112
raise ArgumentError , "#{value} is not a valid stripesize"
113113
end
114114
end
@@ -117,7 +117,7 @@ def insync?(is)
117117
newparam(:readahead) do
118118
desc "The readahead count to use for the new logical volume."
119119
validate do |value|
120-
unless value =~ /^([0-9]+|Auto|None)/i
120+
unless value.to_s =~ /^([0-9]+|Auto|None)/i
121121
raise ArgumentError , "#{value} is not a valid readahead count"
122122
end
123123
end
@@ -158,7 +158,7 @@ def insync?(is)
158158
newparam(:region_size) do
159159
desc "A mirror is divided into regions of this size (in MB), the mirror log uses this granularity to track which regions are in sync. CAN NOT BE CHANGED on already mirrored volume. Take your mirror size in terabytes and round up that number to the next power of 2, using that number as the -R argument."
160160
validate do |value|
161-
unless value =~ /^[0-9]+/i
161+
unless value.to_s =~ /^[0-9]+$/i
162162
raise ArgumentError , "#{value} is not a valid region size in MB."
163163
end
164164
end

spec/unit/type/filesystem_spec.rb

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
require 'spec_helper'
2+
3+
describe Puppet::Type.type(:filesystem) do
4+
5+
it 'raises an ArgumentError when the name is not an absolute path' do
6+
expect {
7+
resource = Puppet::Type.type(:filesystem).new(
8+
{
9+
:name => 'notAnAbsolutePath',
10+
:ensure => :present,
11+
:fs_type => 'ext3',
12+
:options => '-b 4096 -E stride=32,stripe-width=64',
13+
}
14+
)
15+
}.to raise_error(Puppet::ResourceError,
16+
'Parameter name failed on Filesystem[notAnAbsolutePath]: Filesystem names must be fully qualified')
17+
end
18+
19+
it 'does not raise an ArgumentError when the name is an absolute path' do
20+
expect {
21+
resource = Puppet::Type.type(:filesystem).new(
22+
{
23+
:name => '/dev/myvg/mylv',
24+
:ensure => :present,
25+
:fs_type => 'ext3',
26+
:options => '-b 4096 -E stride=32,stripe-width=64',
27+
}
28+
)
29+
}.to_not raise_error
30+
end
31+
end

0 commit comments

Comments
 (0)