Commit graph

767 commits

Author SHA1 Message Date
Matthew Haughton
57a5c0b3e3 (Main) fix typo in pick error message
Update pick error message "at least one non empty value"
2013-10-29 12:01:25 -07:00
Josh Cooper
d809a9ef41 Merge remote-tracking branch 'tchaudhri/tchaudhri_join_func_doc_typo'
* tchaudhri/tchaudhri_join_func_doc_typo:
  Fixed 'separator' typos

Closes GH-196
2013-10-29 11:10:12 -07:00
Tehmasp Chaudhri
753801537f Fixed 'separator' typos 2013-10-25 15:26:21 -06:00
Adrien Thebo
d60d872c1a Merge branch 'pull-180'
This closes GH-180
2013-09-18 21:56:16 -07:00
Adrien Thebo
63811b9d59 (maint) Simplify validate_cmd specs 2013-09-18 21:48:45 -07:00
sgzijl
9e0d8a8e0a (#22214): close content file before executing checkscript
Right now validation seems to be done against zero byte generated temp
files. We need to close the file before executing validation against it.
2013-09-18 21:32:07 -07:00
Adrien Thebo
7ccf8cf09b Merge pull request #184 from lmello/fix_bug_20681_delete_undef_values
delete_undef_values function fix bug #20681
2013-09-18 10:08:49 -07:00
Leonardo Rodrigues de Mello
80a8b7bd1f (#20681) fix behaviour of delete_undef_values
The issue #20681 describe the error of delete() function
removing the elements from the origin array/hash/string.

This issue affected other delete functions. Because
ruby delete and delete_if functions make destructive
changes to the origin array/hash.

The delete_undef_values removed elements from the
origin array/hash and this is not the desired behaviour.

To solve this, we should dup or clone the array/hash
before using the delete or delete_if ruby functions.

We should also check if args[0] is not nil before using
dup, since dup on nil raises exception.

This fix the problem and add unit tests, so we could
enforce this behaviour and prevent regressions.
2013-09-18 11:19:52 -03:00
Adrien Thebo
c2f584d2c2 Merge pull request #183 from lmello/fix_bug_20681_delete_at
delete_at added spec to check against bug #20681
2013-09-17 11:39:29 -07:00
Adrien Thebo
1011670bad Merge pull request #182 from lmello/fix_bug_20681_delete_values
delete_values() fix bug #20681.
2013-09-17 11:35:57 -07:00
Adrien Thebo
f7f70fe9ee Merge pull request #185 from lmello/refactor_16498
(#16498) Added unit test for loadyaml function.
2013-09-17 11:33:57 -07:00
Leonardo Rodrigues de Mello
bcd84f5c3d (#16498) Added unit test for loadyaml function.
As stated on the issue #16498, it would be great to have unit tests
for all the functions.

Function loadyaml was missing a unit test. This commit added the
unit test to loadyaml function.
2013-09-17 15:16:25 -03:00
Adrien Thebo
5cc5e293cf Merge pull request #178 from lmello/fix_bug_20681
bug # 20681 delete() function should not remove elements from original list
2013-09-17 11:07:21 -07:00
Leonardo Rodrigues de Mello
b43c044581 (#20681) delete_at function unit test against issue
The issue #20681 describe the error of delete() function
removing the elements from the origin array/hash/string.

This issue affected the other delete functions.

The delete_at function is not afected by this bug, but
it did not had the unit test to check against it.

I had added the unit test so we could prevent regressions
on the future and also have better test coverage.
2013-09-17 12:09:50 -03:00
Leonardo Rodrigues de Mello
51d96088c1 (#20681) fix behaviour of delete_values
The issue #20681 describe the error of delete() function
removing the elements from the origin array/hash/string.

This issue affected other delete functions. Because
ruby delete and delete_if functions make destructive
changes to the origin array/hash.

The delete_undef_values removed elements from the
origin hash and this is not the desired behaviour.

To solve this, we should dup or clone the hash
before using the delete or delete_if ruby functions.

This fix the problem and add unit tests, so we could
enforce this behaviour and prevent regressions.
2013-09-17 12:05:23 -03:00
Adrien Thebo
ebec9de534 Merge pull request #179 from lmello/function_pick_error_msg
enhanced the error message of pick function.
2013-09-16 13:45:24 -07:00
Leonardo Rodrigues de Mello
c14cbf31e2 bug # 20681 delete() function should not remove elements from original list
The setup: list with 3 elements, delete one:
$test_list = [‘a’, ‘b’, ‘c’]
$test_deleted = delete($test_list, ‘a’)

Print out the elements in ‘test_deleted’:
notify { ‘group_output2’:  withpath => true, name     => “$cfeng::test_deleted”, }
Notice: /Stage[main]/Syslog/Notify[group_output2]/message: bc

Good!  Run-on output shows that ‘a’ was deleted

Print out the elements in ‘test_list’:
notify { ‘group_output1’: withpath => true, name     => “$cfeng::test_list”, }
Notice: /Stage[main]/Syslog/Notify[group_output1]/message: bc

WHAT!?  'a' was deleted from ‘test_list’ as well! Expected abc as output!

This behaviour is confirmed for string, hash and array.
This is fixed on this commit, I had  added two spec tests to cover that cases.

bug #20681 spec test for delete() function.

I had forgot in the last commit the spec test for hash in the
delete function.

bug # 20681 delete() function change aproach.

Instead of rejecting elements from the original list, we use
collection = arguments[0].dup .
then latter we could continue to use delete and gsub! on collection
without impact on original argument.

this is a better solution than the previous one, and works on ruby
1.8.7, 1.9.3 and 2.0.0.

The previous solution does not work on ruby 1.8.7.

delete function remove typo whitespace.

fix typo whitespaces.
2013-09-16 10:19:35 -03:00
Leonardo Rodrigues de Mello
30e994fb6e enhanced the error message of pick function.
When pick function fail return a better error message like
the other stdlib functions, indicating that the error
is on function pick.

This would help people that see the error to identity it is
related to a incorrect use of stdlib function pick, instead of having
to grep all puppet libraries and manifests source for the old message.

I had also changed the spec test.

pick function change spec  as suggested GH-179

Fix the spec test to use expect {}.to instead of lambda {}.should
as explained by Adrienthebo.

"Using expect { }.to is preferred over lambda { }.should.
 In addition it's best practice to do a string match against the
error message to ensure that we're catching the right error,
instead of any error of the right type."

Also fixed a typo on the error message, it was missing one space.

pick function stylish fix as suggested on GH179
2013-09-16 10:03:20 -03:00
Adrien Thebo
079afa5b7f Merge pull request #181 from nibalizer/grammar
Minor grammar fix
2013-09-12 09:57:28 -07:00
Spencer Krum
6bd2b4874c Minor grammar fix 2013-09-11 15:37:59 -07:00
Adrien Thebo
4687b25470 Merge pull request #175 from floatingatoll/patch-1
(maint) fix RST formatting of has_interface_with code examples
2013-09-11 11:13:28 -07:00
Adrien Thebo
f4db73672e Merge pull request #174 from dprince/file_line_after
Update file_line resource to support 'after'.
2013-09-09 11:17:16 -07:00
floatingatoll
34944a78f9 (maint) fix RST formatting of has_interface_with code examples 2013-09-04 10:30:38 -07:00
Jeff McCune
948be0bb99 (maint) Improve the tests and readability of file_line
Without this patch the implementation of the file_line provider is a bit
convoluted with respect to the newly introduced "after" parameter.

This patch addresses the problem by separating out the concerns of each
case into their own methods of handling the behavior with the match
parameter, handling the behavior with the after parameter, or simply
appending the line.
2013-08-29 16:27:27 -07:00
Dan Prince
221277e852 Update file_line resource to support 'after'.
When adding new lines to a file the 'after' option can be useful
when you need to insert file lines into the middle of a file.

This is particularly helpful when using file_line with sectioned
config files.

NOTE: the after option only works when adding new lines. If you are
updating an existing (matched) line it will simply modify it in place.
This assumes it was in the right place to begin with.
2013-08-29 15:07:29 -07:00
Jeff McCune
806430224a (maint) Fix failing spec test with Puppet 3.3.0-rc2
Without this patch the stdlib spec tests are failing against recent
versions of Puppet.  The root cause of this problem is a change in the
behavior of create_resources in Puppet 6baa57b.  The change in behavior
caused the :name key to be omitted from the hash returned by
Puppet::Parser::Resource#to_hash which in turn is causing the test
failure.

This patch addresses the problem by updating the test to match the
description of the example.  Only the attribute :ensure is checked
instead of the full hash itself.
2013-08-29 13:02:31 -07:00
Jeff McCune
10575587f4 (maint) Fix location_for helper method
Without this patch the location_for helper method in the Gemfile
incorrectly assumes the mdata variable has a value.  This patch
addresses the problem by explicitly binding the regular expression match
results to the mdata variable to ensure it has a value when accessed by
index.
2013-08-29 13:02:31 -07:00
Adrien Thebo
6dd6d060df Merge pull request #172 from ptomulik/fix/delete_xxx_spec
small fix to delete_values_spec.rb and README.markdown
2013-08-28 15:39:32 -07:00
Paweł Tomulik
bb9f7d1726 small fix to delete_values_spec.rb and README.markdown 2013-08-14 02:23:36 +02:00
Adrien Thebo
2a78cbfaad Merge pull request #170 from ptomulik/fix_delete_values
minor corrections to delete_values()
2013-08-13 10:27:42 -07:00
Adrien Thebo
66865f2c72 Merge branch 'maint-refactor_validate_slength' 2013-08-12 12:57:55 -07:00
Adrien Thebo
24911db44c (maint) Validate input argument in a single location 2013-08-12 12:56:00 -07:00
Adrien Thebo
200e585ea7 (maint) refactor validate_slength tests 2013-08-12 12:55:46 -07:00
Adrien Thebo
1950b605fb (maint) reindent case statement to match standard indentation 2013-08-12 12:55:46 -07:00
Adrien Thebo
b41883933c (maint) collapse String/Array validation into shared lambda 2013-08-12 12:55:46 -07:00
Adrien Thebo
6df05cbc2d (maint) clean up validate_slength argument validation 2013-08-12 12:55:46 -07:00
Adrien Thebo
e63715ddaf (maint) reword error messages for validate_slength 2013-08-12 11:20:46 -07:00
Adrien Thebo
2cfa408909 (maint) Explicitly unpack validate_slength args 2013-08-12 11:13:46 -07:00
Adrien Thebo
4ad1da83f9 (maint) Remove unneeded parens around exceptions 2013-08-12 11:00:27 -07:00
Adrien Thebo
32dbac0049 Merge pull request #169 from hdeheer/patch-1
Fix validate_slength, arg.length should be args[0].length
2013-08-12 10:49:47 -07:00
Paweł Tomulik
2ba5404b16 minor corrections to delete_values() 2013-08-08 16:56:32 +02:00
Hubert
77625e6d8f Fix validate_slength, arg.length should be args[0].length
During a puppet run an error will be thrown and a puppet run will fail completely (when using validate_slength):
undefined local variable or method `arg' for #<Puppet::Parser::Scope:0x7f243c236948>
2013-08-08 12:56:12 +02:00
Adrien Thebo
0a02295c42 Merge pull request #167 from mhellmic/minlength
extend the validate_slength function to accept a minimum length
2013-08-06 09:48:44 -07:00
Martin Hellmich
0206d367c0 changed the validate_slength function to accept a min length
An optional third parameter can be given a min length. The function
then only passes successfully, if all strings are in the range
min_length <= string <= max_length

update and fix function and unit tests

the check for the minlength has to be written differently
because 0 values should be possible. We now check
a) if the input is convertible, and throw a ParseError and
b) if the input .is_a?(Numeric) and ask for a positive number
it's not as clean as for maxlength, but keeps a similar behaviour

refined the error checking for the min length

try to convert to Integer(args[2]) and fail,
if it's not possible

changed the tests accordingly to the new parameter checking
2013-08-06 10:05:16 +02:00
Adrien Thebo
5544be9276 Merge pull request #166 from ptomulik/delete_undef_values
Add delete_values() and delete_undef_values() functions
2013-08-05 15:29:08 -07:00
Paweł Tomulik
2069415204 added delete_values() and delete_undef_values() functions 2013-08-05 22:12:26 +02:00
Adrien Thebo
e8dcc69193 Merge branch 'uriescape-use_default_escape_list'
This closes GH-164
2013-07-22 13:13:13 -07:00
Tomas Doran
b2e23dc65b Adjust to use default URI.escape escape list
Conform to RFC per comments on: https://github.com/puppetlabs/puppetlabs-stdlib/pull/164

Conflicts:
	lib/puppet/parser/functions/uriescape.rb
	spec/unit/puppet/parser/functions/uriescape_spec.rb
2013-07-22 13:12:28 -07:00
Adrien Thebo
e0d4588bd2 Merge branch 'pull-163'
This closes GH-163
2013-07-11 16:26:45 -07:00
Alex O'Rielly
964a9ad619 (#21416) Allow file_line to match multiple lines
Without this commit the file_line type will outright fail if multiple
lines match the given regex. This commit allows the file_line type and
provider to optionally match and modify all matching lines.

Changeset rebased into a single commit by Adrien Thebo <adrien@puppetlabs.com>
2013-07-11 16:25:56 -07:00