Commit graph

16 commits

Author SHA1 Message Date
David Shrewsbury
1cacf933b7
lineinfile - improve test coverage () 2021-04-06 12:11:10 -04:00
Jose Angel Munoz
69631da889
lineinfile - add search_string parameter for non-regexp searching ()
* Add tests for search_string
* Improve examples
* Add changelog
2021-02-02 15:37:06 -05:00
Robert Osowiecki
3c978a3225 lineinfile - don't run os.makedirs on empty dir path ()
* Fix : don't run os.makedirs on empty dir path

* integration test for lineinfile create: yes without path
2019-10-29 13:06:17 -04:00
Sam Doran
92cd13a2cf
lineinfile - use correct index value when inserting at the end () 2019-10-22 10:39:58 -04:00
Sam Doran
29d4d318a5
lineinfile - properly insert line when line exists and backrefs are enabled ()
Use a separate variable for the boolean test rather than having the same variable sometimes be a boolean and sometimes be a regular expression match object

Add integration tests to cover this scenario
2019-10-22 10:01:11 -04:00
Andrey Klychkov
3b18337cac lineinfile - fix bug with insertbefore/insertafter and firstmatch () 2019-10-08 10:01:36 -04:00
Jérémy Lecour
2fb9b46752 Lineinfile must not insert lines multiples times with insertbefore/insertafter ()
* Change test suite to fit expected behaviour

This reverts some changes from ansible/ansible@723daf3
If a line is found in the file, exactly or via regexp matching, it must 
not be added again.
insertafter/insertbefore options are used only when a line is to be 
inserted, to specify where it must be added.

* Implement the change in behaviour mentioned in the previous commit

* Fix comment to reflect what the code does

* Set the correct return message.

In these cases, the lines are added, not replaced.

* Add a changelog
2018-12-17 16:42:24 -05:00
Sam Doran
b74279d14c Use proper index value with insertbefore on a one line file ()
Add tests and changelog
2018-10-03 17:27:34 -04:00
Matt Clay
4e489d1be8
Update Shippable integration test groups. ()
* Update Shippable integration test groups.
* Update integration test group aliases.
* Rebalance AWS and Azure tests with extra group.
* Rebalance Windows tests with another group.
2018-07-23 20:46:22 -07:00
Sam Doran
fb55038d75 Add warning when using an empty regexp in lineinfile ()
* Revert "Account for empty string regexp in lineinfile ()"

This reverts commit 4b5b4a760c.

* Use context managers for interacting with files

* Store line and regexp parameters in a variable

* Add warning when regexp is an empty string

* Remove '=' from error messages

* Update warning message and add changelog

* Add tests

* Improve warning message

Offer an equivalent regexp that won't trigger the warning.
Update tests to match new warning.

* Add porting guide entry for lineinfile change
2018-06-29 17:15:43 -07:00
Sam Doran
4b5b4a760c
Account for empty string regexp in lineinfile ()
* Use context managers for interacting with files

* Account for empty string as regexp

Rather than explicitly testing for None, also test for an empty string which will evaluate to False. An empty string regexp matches every line, which ends up replacing the incorrect line.

* Store line parameter in a variable

* Add tests
2018-06-25 17:57:05 -04:00
Sam Doran
eaae1318f8
Skip if insertbefore BOF until later ()
If a line match is found in the file and no regexp is specified, insertbefore would improperly try to add a line if set to BOF.

Add tests for this scenario.
2018-06-25 16:24:41 -04:00
Sam Doran
723daf3e3a
Check for regexp match when using insertbefore or insertafter ()
Add tests to cover this scenario
Fixes 
2018-02-21 17:03:38 -05:00
Sam Doran
f8f2b6d61d
Fix lineinfile to insert line when pattern exists elsewhere in the file. ()
* Insert lines before or after when the regexp exists elsewhere in the file

* Correct filter syntax in lineinfile integration test

* Use multi-line YAML syntax on lineinfile tests

Unify indentation

* Add lineinfile tests for same line matched to different regexps

* Remove debug statement from test
2018-02-01 16:45:26 -05:00
Matt Clay
6bbd92e422 Initial ansible-test implementation. () 2016-11-29 21:21:53 -08:00
Matt Clay
75e4645ee7 Migrate Linux CI roles to test targets. () 2016-10-13 09:09:25 -07:00