1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
|
#######################################################
#
# Test insert_ini_section
#
#######################################################
body common control
{
inputs => { '../../default.cf.sub' };
bundlesequence => { default("$(this.promise_filename)") };
version => "1.0";
}
#######################################################
bundle agent init
{
files:
# The tested file "actual" is copied from our seeded starting position.
"$(G.testfile).actual"
copy_from => local_cp("$(this.promise_filename).start");
# Next we place the file which we will compare the final result with.
"$(G.testfile).expected"
copy_from => local_cp("$(this.promise_filename).finish");
}
#######################################################
bundle agent test
{
meta:
"description" -> { "CFE-2721" }
string => "Test that insert_ini_section works with more than one section";
cfengine_3_7::
"test_soft_fail"
string => "any",
meta => { "CFE-2721" };
vars:
"options[test][test_option_one]" string => "test_option_one_value";
"options[fake][fake_option_one]" string => "fake_option_one_value";
# TODO: refactor after 3.7.x is EOL
"sections_indices" slist => getindices(options);
"sections_sorted" slist => sort("sections_indices", lex);
"sections" slist => reverse("sections_sorted");
files:
"$(G.testfile).actual"
edit_line => insert_ini_section( $(sections), "$(this.bundle).options[$(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) );
}
|