File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # frozen_string_literal: true
2+
3+ require 'test'
4+ require 'securerandom'
5+ require 'temporalio/testing'
6+ require 'temporalio/worker'
7+ require 'polling/infrequent/greeting_workflow'
8+ require 'polling/infrequent/compose_greeting_activity'
9+ require 'polling/infrequent/test_service'
10+
11+ module Polling
12+ module Infrequent
13+ class GreetingWorkflowTest < Test
14+ def test_workflow_completes_after_polling
15+ skip_if_not_x86!
16+ task_queue = "tq-#{ SecureRandom . uuid } "
17+
18+ Temporalio ::Testing ::WorkflowEnvironment . start_time_skipping do |env |
19+ worker = Temporalio ::Worker . new (
20+ client : env . client ,
21+ task_queue : task_queue ,
22+ activities : [ Polling ::Infrequent ::ComposeGreetingActivity ] ,
23+ workflows : [ Polling ::Infrequent ::GreetingWorkflow ]
24+ )
25+
26+ handle = env . client . start_workflow (
27+ Polling ::Infrequent ::GreetingWorkflow ,
28+ 'Temporal' ,
29+ id : "wf-#{ SecureRandom . uuid } " ,
30+ task_queue : task_queue
31+ )
32+
33+ worker . run do
34+ # Advance time forward to allow for the 4 retries (4 * 60s) plus a buffer
35+ env . sleep ( 241 )
36+
37+ # Wait for the workflow to complete and assert its result
38+ result = handle . result
39+ assert_equal ( 'Hello, Temporal!' , result )
40+ end
41+ end
42+ end
43+ end
44+ end
45+ end
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 33require 'minitest/autorun'
44
55class Test < Minitest ::Test
6+ def skip_if_not_x86!
7+ skip ( 'Test only supported on x86' ) unless RbConfig ::CONFIG [ 'host_cpu' ] == 'x86_64'
8+ end
69end
You can’t perform that action at this time.
0 commit comments