#!/var/cfengine/bin/cf-agent -f-
body common control
{
      inputs => { "../../default.cf.sub" };
      bundlesequence => {
                          default("$(this.promise_filename)") };
      version => "1.0";
}
body file control {  namespace => "test"; }
bundle agent example
{
  classes:
    "TRIGGERED"
      expression => "any",
      scope => "bundle"; # Namespace scoped classes are visible from other bundles
}
bundle agent check
{
  classes:
    # Expectation, default:TRIGGERED is NOT defined
    "default_TRIGGERED_OK"
      expression => "!default:TRIGGERED";

    # Expectation, test:TRIGGERED is NOT defined (not visable since it's a bundle scoped class)
    "namespaced_TRIGGERED_OK"
      expression => "!test:TRIGGERED";

    # Expectation, TRIGGERED is NOT defined, we are now in the test namespace where the TRIGGERED class was defined, but it was bundle scoped, so not visable from another bundle
    "TRIGGERED_OK"
      expression => "!TRIGGERED";


    "pass" and => {
                    "default_TRIGGERED_OK",
                    "namespaced_TRIGGERED_OK",
                    "TRIGGERED_OK",
                  };
  reports:
    pass::
    "Pass $(this.promise_filename)";
    !pass::
    "FAIL $(this.promise_filename)";
    !default_TRIGGERED_OK::
    "Expected 'default:TRIGGERED' to not be seen as defined, but expression '!default:TRIGGERED' resulted in true";
    !namespaced_TRIGGERED_OK::
    "Expected 'test:TRIGGERED' to NOT be seen as defined, but expression '!test:TRIGGERED' resulted in false";
    !TRIGGERED_OK::
    "Expected 'TRIGGERED' to NOT be seen as defined, but expression '!TRIGGERED' resulted in false";

}
body file control {  namespace => "default"; }
bundle agent test
{
  meta:
    "description" -> {"ENT-4681" }

      string => "Test that bundle scoped classes defined from namespaced
      agent bundles are properly scoped. Specifically from the perspective of
      the non-default namespace itself.";


    "test_soft_fail"
      string => "any",
      meta => { "ENT-4681" };

  methods:
    "test:example";
}
bundle agent check
{
  methods:
    "test:check";
}
bundle agent __main__
{

  methods:
    "test";
    "check";
}
