Skip to content

Commit 2bb8035

Browse files
committed
Added acceptance test for allow_non_convergent option in replace_pattern
Signed-off-by: Victor Moene <[email protected]>
1 parent 12b5eba commit 2bb8035

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#######################################################
2+
#
3+
# Replace a pattern using non-convergent regexes
4+
#
5+
#######################################################
6+
7+
body common control
8+
{
9+
inputs => { "../../default.cf.sub" };
10+
bundlesequence => { default("$(this.promise_filename)") };
11+
version => "1.0";
12+
}
13+
14+
######################################################
15+
16+
bundle agent init
17+
{
18+
files:
19+
"/tmp/example.txt"
20+
content => "foo PORT=23 bar";
21+
22+
}
23+
24+
######################################################
25+
26+
bundle agent test
27+
{
28+
files:
29+
"/tmp/example.txt"
30+
edit_line => _regex_replace( "PORT=[0-9]+", "PORT=22" );
31+
}
32+
33+
bundle edit_line _regex_replace(find,replace)
34+
{
35+
replace_patterns:
36+
"$(find)"
37+
replace_with => _value("$(replace)"),
38+
comment => "Search and replace string",
39+
allow_non_convergent => "true";
40+
}
41+
42+
body replace_with _value(x)
43+
{
44+
replace_value => "$(x)";
45+
occurrences => "all";
46+
}
47+
48+
######################################################
49+
50+
bundle agent check
51+
{
52+
vars:
53+
"file_content"
54+
string => readfile( "/tmp/example.txt" , "999" );
55+
56+
classes:
57+
"ok" expression => strcmp("$(file_content)", "foo PORT=22 bar");
58+
59+
files:
60+
"/tmp/example.txt"
61+
delete => tidy;
62+
63+
reports:
64+
ok::
65+
"$(this.promise_filename) Pass";
66+
!ok::
67+
"$(this.promise_filename) FAIL";
68+
}
69+

0 commit comments

Comments
 (0)