Skip to content

Commit

Permalink
Added test that set_variable_values_ini does not error when keys are …
Browse files Browse the repository at this point in the history
…not present in promised section

Ticket: CFE-3866
Changelog: None
  • Loading branch information
nickanderson committed Nov 11, 2021
1 parent cf7f750 commit 28d6187
Show file tree
Hide file tree
Showing 4 changed files with 114 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#######################################################
#
# Test bundle set_config_values_ini
#
#######################################################

body common control
{
inputs => { '../../default.cf.sub' };
bundlesequence => { default("$(this.promise_filename)") };
version => "1.0";
}

#######################################################


bundle agent test
{
meta:
"description" -> { "CFE-3866" }
string => "Test that set_variable_values_ini does not error when promised key is not present";

}

#######################################################

bundle agent check
{

methods:

"Pass/FAIL"
usebundle => dcs_passif_output(".*", ".*error.*", "$(sys.cf_agent) -Kf $(this.promise_filename).sub --define AUTO", $(this.promise_filename));

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#######################################################
#
# Test bundle set_config_values_ini
#
#######################################################

body common control
{
inputs => { '../../default.cf.sub' };
bundlesequence => { default("$(this.promise_filename)") };
version => "1.0";
}

#######################################################

bundle agent init
{
files:

"$(G.testfile).actual"
copy_from => local_cp("$(this.promise_filename).start");


"$(G.testfile).expected"
copy_from => local_cp("$(this.promise_filename).finish");

}

#######################################################

bundle agent test
{
meta:
"description" -> { "CFE-3866" }
string => "Test that set_variable_values_ini does not error when promised key is not present";

vars:
"config[section 1][present_at_start]" string => "1";
"config[section 1][absent_at_start]" string => "1";
"config[section 2][present_at_start]" string => "two";
"sections" slist => getindices( config );

files:

"$(G.testfile).actual"
edit_line => set_variable_values_ini("test.config", "$(sections)");

}

#######################################################

bundle agent check
{

methods:

"check"
usebundle => dcs_if_diff( "$(G.testfile).actual", "$(G.testfile).expected",
"pass", "_fail");

# Fail the test if any of the files fail.
"fail"
usebundle => dcs_fail( $(this.promise_filename) ),
if => "_fail";

pass::
"pass"
usebundle => dcs_pass( $(this.promise_filename) );

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[section 1]
present_at_start=1
absent_at_start=1
[section 2]
present_at_start=two
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[section 1]
present_at_start=1
[section 2]
present_at_start=two

0 comments on commit 28d6187

Please sign in to comment.