@@ -562,16 +562,27 @@ def test_worker_shutdown
562562 class AsyncCompletionActivity < Temporalio ::Activity ::Definition
563563 def initialize
564564 @task_token = Queue . new
565+ @id_ref = Queue . new
565566 end
566567
567568 def execute
568- @task_token . push ( Temporalio ::Activity ::Context . current . info . task_token )
569+ info = Temporalio ::Activity ::Context . current . info
570+ @task_token . push ( info . task_token )
571+ @id_ref . push ( Temporalio ::Client ::ActivityIDReference . new (
572+ workflow_id : info . workflow_id ,
573+ run_id : info . workflow_run_id ,
574+ activity_id : info . activity_id
575+ ) )
569576 raise Temporalio ::Activity ::CompleteAsyncError
570577 end
571578
572579 def wait_task_token
573580 @task_token . pop
574581 end
582+
583+ def wait_id_ref
584+ @id_ref . pop
585+ end
575586 end
576587
577588 def test_async_completion_success
@@ -629,6 +640,70 @@ def test_async_completion_cancel
629640 end
630641 end
631642
643+ def test_async_completion_cancel_details
644+ # Cancel
645+ act = AsyncCompletionActivity . new
646+ execute_activity ( act , wait_for_cancellation : true ) do |handle |
647+ task_token = act . wait_task_token
648+ handle . cancel
649+ assert_eventually do
650+ err = assert_raises ( Temporalio ::Error ::AsyncActivityCanceledError ) do
651+ env . client . async_activity_handle ( task_token ) . heartbeat
652+ end
653+ assert err . details . cancel_requested?
654+ refute err . details . paused?
655+ refute err . details . reset?
656+ end
657+ end
658+
659+ # Pause
660+ act = AsyncCompletionActivity . new
661+ execute_activity ( act , wait_for_cancellation : true ) do
662+ id_ref = act . wait_id_ref
663+ env . client . workflow_service . pause_activity ( Temporalio ::Api ::WorkflowService ::V1 ::PauseActivityRequest . new (
664+ namespace : env . client . namespace ,
665+ execution : Temporalio ::Api ::Common ::V1 ::WorkflowExecution . new (
666+ workflow_id : id_ref . workflow_id ,
667+ run_id : id_ref . run_id
668+ ) ,
669+ identity : env . client . connection . options . identity ,
670+ id : id_ref . activity_id ,
671+ reason : 'my reason'
672+ ) )
673+ assert_eventually do
674+ err = assert_raises ( Temporalio ::Error ::AsyncActivityCanceledError ) do
675+ env . client . async_activity_handle ( id_ref ) . heartbeat
676+ end
677+ refute err . details . cancel_requested?
678+ assert err . details . paused?
679+ refute err . details . reset?
680+ end
681+ end
682+
683+ # Reset
684+ act = AsyncCompletionActivity . new
685+ execute_activity ( act , wait_for_cancellation : true ) do
686+ id_ref = act . wait_id_ref
687+ env . client . workflow_service . reset_activity ( Temporalio ::Api ::WorkflowService ::V1 ::ResetActivityRequest . new (
688+ namespace : env . client . namespace ,
689+ execution : Temporalio ::Api ::Common ::V1 ::WorkflowExecution . new (
690+ workflow_id : id_ref . workflow_id ,
691+ run_id : id_ref . run_id
692+ ) ,
693+ identity : env . client . connection . options . identity ,
694+ id : id_ref . activity_id
695+ ) )
696+ assert_eventually do
697+ err = assert_raises ( Temporalio ::Error ::AsyncActivityCanceledError ) do
698+ env . client . async_activity_handle ( id_ref ) . heartbeat
699+ end
700+ refute err . details . cancel_requested?
701+ refute err . details . paused?
702+ assert err . details . reset?
703+ end
704+ end
705+ end
706+
632707 def test_async_completion_timeout
633708 act = AsyncCompletionActivity . new
634709 execute_activity ( act , start_to_close_timeout : 0.5 , wait_for_cancellation : true ) do
0 commit comments