#######################################################
#
# Files read in as templates, check class handling
#
#######################################################

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

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

bundle agent init
{
  files:
      "$(G.testfile).expected"
      create => "true",
      edit_line => init_expected,
      edit_defaults => init_empty;

  files:
      "$(G.testfile).template"
      create => "true",
      edit_line => init_template,
      edit_defaults => init_empty;

}

#######

bundle edit_line init_template
{
insert_lines:

"[%CFEngine BEGIN %]
WARNING
No unauthorized logins. All logins are recorded.
Property of Example.com
[%CFEngine END %]

[%CFEngine nosuchclass:: %]
manager: Mr. White <mwhite@example.com>
phone: 555-555-5555

[%CFEngine fishy:: %]
manager: Mr. Black <mblack@example.com>
phone: 555-555-4444

[%CFEngine any:: %]
AAAAAAAA
"

insert_type => "preserve_all_lines";
}

#######

bundle edit_line init_expected
{
insert_lines:

"WARNING
No unauthorized logins. All logins are recorded.
Property of Example.com

manager: Mr. Black <mblack@example.com>
phone: 555-555-4444

AAAAAAAA
"

insert_type => "preserve_block";
}

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

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

bundle agent test
{
classes:

  "fishy" expression => "any";

files:

   "$(G.testfile).actual"
           create => "true",
    edit_template => "$(G.testfile).template";
}

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

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

### PROJECT_ID: core
### CATEGORY_ID: 27
