# Test that namespaced bundles that call other namespaced bundles can do so
# without specifying their own namespace
# Redmine:4289 (https://cfengine.com/dev/issues/4289)
body common control
{
  inputs => { "../../default.sub.cf" };
  bundlesequence => { default("$(this.promise_filename)") };
  version => "1.0";
}

bundle agent init
{
}

bundle agent test
{
  vars:
    "agent_output"
      string => execresult(
        "$(sys.cf_agent) -KIf $(this.promise_filename).sub -b testing:one",
        "noshell"
      );
}

bundle agent check
{
  classes:
    "OK_non_specified_namespace"
      expression => regcmp(".*OKI DOKI.*", $(test.agent_output));

    "OK_specified_namespace"
      expression => regcmp(".*artichokie.*", $(test.agent_output));

    "ok" and => { "OK_non_specified_namespace", "OK_specified_namespace" };

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

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

    DEBUG::
      "agent output: 
===============================================================================
$(test.agent_output)
===============================================================================";
}
