body common control
{
      # Feel free to avoid including "default.cf.sub" and define your
      # own bundlesequence for simple tests

      inputs => { "../../../default.cf.sub" };
      bundlesequence  => { default("$(this.promise_filename)") };
}

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

bundle agent init
# Initialize the environment and prepare for test
{

}

bundle agent test
# Activate policy for behaviour you wish to inspect
{
  meta:
    "description" -> { "CFE-3656" }
      string => "def_preferred.json is preferred over def.json if it exists.";
  classes:
    "ok"
      if => and(
        strcmp(length(variablesmatching(".*\.good_var")), "1"),
        strcmp(length(variablesmatching(".*\.bad_var")),  "0"),
        fileexists("$(this.promise_dirname)/def.json"),
        fileexists("$(this.promise_dirname)/def_preferred.json")),
      scope => "namespace";
}

bundle agent check
# Check the result of the test
{
  reports:
    ok::
      "$(this.promise_filename) Pass";
    !ok::
      "$(this.promise_filename) FAIL";
}
