workflow::test::run_bug_tracker_test (public)
workflow::test::run_bug_tracker_test [ -create_proc create_proc ]
Defined in packages/workflow/tcl/test/workflow-test-procs.tcl
- Switches:
- -create_proc (optional, defaults to
"workflow_setup"
)- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
Source code: # Make sure to run the teardown proc even if there is an error set test_chunk { # Setup set workflow_id [$create_proc] set generated_spec [workflow::fsm::generate_spec -workflow_id $workflow_id] if { ![aa_true "Checking that generated spec 1 is identical to the spec that we created from (except for ordering)" [array_lists_equal_p $generated_spec [workflow_get_array_style_spec]]] } { ns_log Error "Workflow test case failed: \nDesired spec: [workflow_get_array_style_spec]\n\nActual spec:\n\n[util::array_list_spec_pretty $generated_spec]" } # Create the workflow case in open state set object_id [workflow::test::workflow_object_id] set case_id [workflow::test::case_setup] set retrieved_case_id [workflow::case::get_id -object_id $object_id -workflow_short_name [workflow::test::workflow_name]] # Test the workflow::get proc workflow::get -workflow_id $workflow_id -array workflow_array aa_equals "checking the short_name retrieved with workflow::get of workflow" $workflow_array(short_name) [workflow::test::workflow_name] set retrieved_initial_action_name [workflow::action::get_element -action_id $workflow_array(initial_action_id) -element short_name] aa_equals "Checking initial action short name from workflow::get and workflow::action::get_element" $retrieved_initial_action_name [workflow::test::initial_action_short_name] # Test changing the short_name and check that the flush is cached # TODO... # Get the role short_names set expect_role_names [list submitter assignee] foreach role_id [workflow::get_roles -workflow_id $workflow_id] { workflow::role::get -role_id $role_id -array role aa_true "checking that role names of workflow can be fetched with workflow::get_roles and workflow::role::get" {$role(short_name) in $expect_role_names} } # Get the action short names set expect_action_names [list open comment edit resolve close reopen] foreach action_id [workflow::get_actions -workflow_id $workflow_id] { workflow::action::get -action_id $action_id -array action aa_true "checking retrieval of action names with workflow::get_actions and workflow::get" {$action(short_name) in $expect_action_names} } # Get the state short names # TODO aa_equals "case_id of a created workflow case should be retrievable" $case_id $retrieved_case_id set expect_enabled_actions [list comment edit resolve] workflow::test::assert_case_state -workflow_id $workflow_id -case_id $case_id -expect_current_state open -expect_enabled_actions $expect_enabled_actions -expect_user_actions $expect_enabled_actions # Resolve the bug workflow::case::action::execute -case_id $case_id -action_id [workflow::action::get_id -workflow_id $workflow_id -short_name "resolve"] -comment "Resolving Bug" -comment_mime_type "text/plain" -user_id [workflow::test::admin_owner_id] set expect_enabled_actions [list comment edit resolve reopen close] workflow::test::assert_case_state -workflow_id $workflow_id -case_id $case_id -expect_current_state resolved -expect_enabled_actions $expect_enabled_actions -expect_user_actions $expect_enabled_actions ##### # # Intermezzo: Check cache and flushing # ##### # -1. Basic sanity check aa_equals "Stat is resolved" [workflow::case::get_element -case_id $case_id -element state_short_name] "resolved" # 0. Desired output global desired_output set desired_output [workflow::case::fsm::get_info_not_cached $case_id] # 1. Make sure the cache is populated set dummy [workflow::case::get_element -case_id $case_id -element state_short_name] ad_try { # 2. Stub the cache proc aa_stub workflow::case::fsm::get_info_not_cached { # Note that we got called global i_got_called_p desired_output set i_got_called_p 1 return $desired_output } global i_got_called_p # 3. Check that it doesn't call stubbed proc set i_got_called_p 0 set dummy [workflow::case::get_element -case_id $case_id -element state_short_name] aa_false "Check that the value is in the cache (1st time)" $i_got_called_p # 4. Flush workflow::case::flush_cache -case_id $case_id # 5. Check that it DOES call stubbed proc set i_got_called_p 0 set dummy [workflow::case::get_element -case_id $case_id -element state_short_name] aa_true "Check that the value is NOT in the cache (1st time)" $i_got_called_p # 6. Manually populate the cache util_memoize_seed [list workflow::case::fsm::get_info_not_cached $case_id] $desired_output [workflow::case::cache_timeout] # 7. Check that it doesn't call stubbed proc set i_got_called_p 0 set dummy [workflow::case::get_element -case_id $case_id -element state_short_name] aa_false "Check that the value is in the cache (2nd time)" $i_got_called_p # 8. Flush workflow::case::flush_cache # 9. Check that it DOES call stubbed proc set i_got_called_p 0 set dummy [workflow::case::get_element -case_id $case_id -element state_short_name] aa_true "Check that the value is NOT in the cache (2nd time)" $i_got_called_p } on error {errorMsg} { error $errorMsg $::errorInfo } finally { # 10. Unstub aa_unstub workflow::case::fsm::get_info_not_cached } ##### # # Continue with case # ##### # Close the bug workflow::case::action::execute -case_id $case_id -action_id [workflow::action::get_id -workflow_id $workflow_id -short_name "close"] -comment "Closing Bug" -comment_mime_type "text/plain" -user_id [workflow::test::admin_owner_id] set expect_enabled_actions [list comment edit reopen] workflow::test::assert_case_state -workflow_id $workflow_id -case_id $case_id -expect_current_state closed -expect_enabled_actions $expect_enabled_actions -expect_user_actions $expect_enabled_actions } set error_p [catch $test_chunk errMsg] # Teardown workflow::test::workflow_teardown if { $error_p } { aa_false "error during setup: $errMsg - $::errorInfo" $error_p }XQL Not present: Generic, PostgreSQL, Oracle