#######################################################
#
# Test instatiation of template blocks larger than 4096 characters.
# Redmine #3852
#
#######################################################
body common control
{
  inputs => { "../../default.sub.cf" };
  bundlesequence => { default("$(this.promise_filename)") };
  version => "1.0";
}

#######################################################
bundle agent init
{
  vars:
    "origtestdir" string => dirname("$(this.promise_filename)");

  files:
    "$(G.testfile)" delete => init_delete;
}

body delete init_delete
{
  dirlinks => "delete";
  rmdirs => "true";
}

#######################################################
bundle agent test
{
  vars:
    "template_file" string => "$(this.promise_filename).template";

  classes:

  files:
    "$(G.testfile)"
      create => "true",
      edit_template => "$(template_file)";

  reports:
    DEBUG::
      "Rendering template file $(template_file) to $(G.testfile)";
}

#######################################################
bundle agent check
{
  vars:
    "expected" int => "110";
    "actual" int => countlinesmatching(".*0123456789.*", "$(G.testfile)");

  classes:
    "ok" expression => strcmp("$(expected)", "$(actual)");

  reports:
    DEBUG::
      "expected: '$(expected)'";
      "actual: '$(actual)'";

    ok::
      "$(this.promise_filename) Pass";

    !ok::
      "$(this.promise_filename) FAIL";
}
