# Test matching packages with explicit default architecture set and the same
# architecture in list of installed packages. Should work similar to the case
# there are no architectures at all.
#
# List of installed packages contains a single package with the default
# architecture specified.
body common control
{
  inputs => { "../default.sub.cf" };
  bundlesequence => { default("$(this.promise_filename)") };
  version => "1.0";
}

bundle agent init
{
  vars:
    "dummy" string => "dummy";
}

bundle agent test
{
  packages:
    # Test that package is matched by a promise with no package_architectures
    # constraint, as it means "any architecture"
    "foobar"
      package_version => "1",
      package_policy => "addupdate",
      package_method => mock,
      classes => kept("ok_1");

    # Test that specifying proper architecture explicitly matches the package.
    "foobar"
      package_version => "1",
      package_architectures => { "setun" },
      package_policy => "addupdate",
      package_method => mock,
      classes => kept("ok_2");

    # Test that specifying wrong architecture explicitly does not match the package.
    "foobar"
      package_version => "1",
      package_architectures => { "aldan" },
      package_policy => "addupdate",
      package_method => mock,
      classes => fail("ok_3");
}

body package_method mock
{
  package_changes => "individual";
  package_default_arch_command => "$(G.printf) 'setun'";
  package_list_command => "$(G.printf) 'foobar-1-setun'";
  package_list_name_regex => "^([^-]+)";
  package_list_version_regex => "^[^-]+-([^-]+)";
  package_list_arch_regex => "^[^-]+-[^-]+-([\S]+)";
  package_installed_regex => ".*";
  package_add_command => "$(G.false)";
  package_update_command => "$(G.false)";
  package_delete_command => "$(G.false)";
  package_verify_command => "$(G.false)";
}

body classes kept(classname)
{
  promise_kept => { "$(classname)" };
}

body classes fail(classname)
{
  repair_failed => { "$(classname)" };
}

bundle agent check
{
  classes:
    "ok" and => { "ok_1", "ok_2", "ok_3" };

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

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

### PROJECT_ID: core
### CATEGORY_ID: 29
