#######################################################
#
# Copy symlink over file, test that file is correctly saved aside.
#
#######################################################
body common control
{
  inputs => { "../../default.sub.cf" };
  bundlesequence => { default("$(this.promise_filename)") };
  version => "1.0";
}

bundle common g
{
  vars:
    "srcfile" string => "$(G.testfile).source";
}

#######################################################
bundle agent init
{
  files:
    "$(G.testfile)"
      move_obstructions => "true",
      copy_from => init_copy;

    "$(g.srcfile)"
      move_obstructions => "true",
      link_from => init_link;
}

body copy_from init_copy
{
  source => "$(G.etc_group)";
  compare => "digest";
}

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

body link_from init_link
{
  source => "$(G.true)";
}

#######################################################
bundle agent test
{
  meta:
    "test_skip_unsupported" string => "windows";

  files:
    "$(G.testfile)"
      move_obstructions => "true",
      copy_from => test_copy;
}

body copy_from test_copy
{
  source => "$(g.srcfile)";
  compare => "digest";
}

#######################################################
bundle agent check
{
  classes:
    "ok" expression => fileexists("$(G.testfile).cfsaved");

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

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

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