#######################################################
#
# Insert lines from a variable, verify that whitespace_policy other than
# ignore_leading works when given a not-close-enough match
#
#######################################################

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

bundle agent init
{
  vars:
      "states" slist => { "actual", "expected" };

      "actual" string =>
      "BEGIN
    One potato
    Two potato
    Two potatoes
    Leading   embedded   and trailing spaces   
    Four
END";
      
      "insert" string =>
      "    One potato
    Two potato
    Three potatoe
    Leading embedded and trailing spaces   
    Four";

      "expected" string =>
      "BEGIN
    One potato
    Two potato
    Two potatoes
    Leading   embedded   and trailing spaces   
    Four
END
    Three potatoe
    Leading embedded and trailing spaces   ";
      
  files:
      "$(G.testfile).$(states)"
      create => "true",
      edit_line => init_insert("$(init.$(states))"),
      edit_defaults => init_empty;
}

bundle edit_line init_insert(str)
{
  insert_lines:
      "$(str)";
}

body edit_defaults init_empty
{
      empty_file_before_editing => "true";
}

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

bundle agent test
{
  files:
      "$(G.testfile).actual"
      edit_line => test_insert("$(init.insert)");
}

bundle edit_line test_insert(lines)
{
  insert_lines:
      "$(lines)"
      whitespace_policy => { "exact_match", "ignore_embedded", "ignore_trailing" };
}

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

bundle agent check
{
  methods:
      "any" usebundle => dcs_check_diff("$(G.testfile).actual",
					    "$(G.testfile).expected",
					    "$(this.promise_filename)");
}
### PROJECT_ID: core
### CATEGORY_ID: 27
