Skip to content

Commit 28d6187

Browse files
committed
Added test that set_variable_values_ini does not error when keys are not present in promised section
Ticket: CFE-3866 Changelog: None
1 parent cf7f750 commit 28d6187

4 files changed

+114
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#######################################################
2+
#
3+
# Test bundle set_config_values_ini
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+
17+
bundle agent test
18+
{
19+
meta:
20+
"description" -> { "CFE-3866" }
21+
string => "Test that set_variable_values_ini does not error when promised key is not present";
22+
23+
}
24+
25+
#######################################################
26+
27+
bundle agent check
28+
{
29+
30+
methods:
31+
32+
"Pass/FAIL"
33+
usebundle => dcs_passif_output(".*", ".*error.*", "$(sys.cf_agent) -Kf $(this.promise_filename).sub --define AUTO", $(this.promise_filename));
34+
35+
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#######################################################
2+
#
3+
# Test bundle set_config_values_ini
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+
20+
"$(G.testfile).actual"
21+
copy_from => local_cp("$(this.promise_filename).start");
22+
23+
24+
"$(G.testfile).expected"
25+
copy_from => local_cp("$(this.promise_filename).finish");
26+
27+
}
28+
29+
#######################################################
30+
31+
bundle agent test
32+
{
33+
meta:
34+
"description" -> { "CFE-3866" }
35+
string => "Test that set_variable_values_ini does not error when promised key is not present";
36+
37+
vars:
38+
"config[section 1][present_at_start]" string => "1";
39+
"config[section 1][absent_at_start]" string => "1";
40+
"config[section 2][present_at_start]" string => "two";
41+
"sections" slist => getindices( config );
42+
43+
files:
44+
45+
"$(G.testfile).actual"
46+
edit_line => set_variable_values_ini("test.config", "$(sections)");
47+
48+
}
49+
50+
#######################################################
51+
52+
bundle agent check
53+
{
54+
55+
methods:
56+
57+
"check"
58+
usebundle => dcs_if_diff( "$(G.testfile).actual", "$(G.testfile).expected",
59+
"pass", "_fail");
60+
61+
# Fail the test if any of the files fail.
62+
"fail"
63+
usebundle => dcs_fail( $(this.promise_filename) ),
64+
if => "_fail";
65+
66+
pass::
67+
"pass"
68+
usebundle => dcs_pass( $(this.promise_filename) );
69+
70+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[section 1]
2+
present_at_start=1
3+
absent_at_start=1
4+
[section 2]
5+
present_at_start=two
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[section 1]
2+
present_at_start=1
3+
[section 2]
4+
present_at_start=two

0 commit comments

Comments
 (0)