#######################################################
#
# Ensure that the transformer runs for every file in a recursive tree
#
#######################################################

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

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

bundle agent init
{
  vars:
    any::
      "files" slist => { "1", "2", "3" };

  files:
      "$(G.testdir)/."
      create => "true";

      "$(G.testdir)/$(files)"
      copy_from => init_copy("$(G.etc_group)");
}

body copy_from init_copy(file)
{
      source => "$(file)";
}

body classes init_set_class(class)
{
      promise_kept => { "$(class)" };
      promise_repaired => { "$(class)" };
}

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

bundle agent test
{
  files:
      "$(G.testdir)"
      transformer => "$(G.gzip) $(this.promiser)",
      file_select => test_plain,
      depth_search => test_recurse;
}

body file_select test_plain
{
      file_types => { "plain" };
      file_result => "file_types";
}

body depth_search test_recurse
{
      depth => "inf";
}

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

bundle agent check
{
  vars:
      "files" slist => { @{init.files} };

  classes:
      "ok$(files)" expression => fileexists("$(G.testdir)/$(files).gz");
      "ok" and => { "ok1", "ok2", "ok3" };

  reports:
    DEBUG::
      "$(G.testdir)/$(files).gz exists as expected"
      if => "ok$(files)";
      "$(G.testdir)/$(files).gz was not created!"
      if => "!ok$(files)";
    ok::
      "$(this.promise_filename) Pass";
    !ok::
      "$(this.promise_filename) FAIL";
}
### PROJECT_ID: core
### CATEGORY_ID: 27
