acs::test::require_package_instance (public)

 acs::test::require_package_instance -package_key package_key \
    [ -instance_name instance_name ] [ -empty ]

Defined in packages/acs-automated-testing/tcl/aa-test-procs.tcl

Returns a test instance of specified package_key mounted under specified name. Will create it if it is not found. It is currently assumed the instance will be mounted under the main subsite.

Switches:
-package_key (required)
package to be instantiated
-instance_name (optional)
name of the site-node this instance will be mounted to. Will default to -test
-empty (optional, boolean)
require an empty instance. If an existing instance is found, it will be deleted. If a package different than is found, it won't be deleted and the proc will return an error
Returns:
a package_id

Partial Call Graph (max 5 caller/called nodes):
%3 test_create_form_with_form_instance create_form_with_form_instance (test xowiki) acs::test::require_package_instance acs::test::require_package_instance test_create_form_with_form_instance->acs::test::require_package_instance test_create_form_with_numeric create_form_with_numeric (test xowiki) test_create_form_with_numeric->acs::test::require_package_instance test_form_validate form_validate (test xowiki) test_form_validate->acs::test::require_package_instance test_includelet_childresources includelet_childresources (test xowiki) test_includelet_childresources->acs::test::require_package_instance test_includelet_toc includelet_toc (test xowiki) test_includelet_toc->acs::test::require_package_instance apm_package_key_from_id apm_package_key_from_id (public) acs::test::require_package_instance->apm_package_key_from_id db_0or1row db_0or1row (public) acs::test::require_package_instance->db_0or1row site_node::delete site_node::delete (public) acs::test::require_package_instance->site_node::delete site_node::get_element site_node::get_element (public) acs::test::require_package_instance->site_node::get_element site_node::instantiate_and_mount site_node::instantiate_and_mount (public) acs::test::require_package_instance->site_node::instantiate_and_mount xowf::test::require_test_instance xowf::test::require_test_instance (private) xowf::test::require_test_instance->acs::test::require_package_instance

Testcases:
package_normalize_path, includelet_toc, includelet_childresources, link_tests, slot_interactions, path_resolve, create_form_with_form_instance, create_form_with_numeric, form_validate, nested_self_references
Source code:
        set main_node_id [site_node::get_element  -url / -element node_id]

        set instance_name [expr {$instance_name eq "" ?
                                 "${package_key}-test" : [string trim $instance_name /]}]

        set package_exists_p [db_0or1row lookup_test_package {
            select node_id, object_id as package_id
            from site_nodes
            where parent_id = :main_node_id
            and name = :instance_name
            and object_id is not null
        }]

        if {$package_exists_p} {
            set existing_package_key [apm_package_key_from_id $package_id]
            if {$existing_package_key ne $package_key} {
                error "An instance of '$existing_package_key' is already mounted at '$instance_name'"
            } elseif {$empty_p} {
                site_node::delete -node_id $node_id -delete_package
            }
        }

        if {!$package_exists_p || $empty_p} {
            set package_id [site_node::instantiate_and_mount  -package_name $instance_name  -node_name $instance_name  -package_key $package_key]
        }

        return $package_id
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: