@@ -91,6 +91,19 @@ def generator_function_with_serialization(context):
91
91
92
92
return outputs
93
93
94
+ def generator_function_new_guid (context ):
95
+ """Simple orchestrator that generates 3 GUIDs"""
96
+ outputs = []
97
+
98
+ output1 = context .new_guid ()
99
+ output2 = context .new_guid ()
100
+ output3 = context .new_guid ()
101
+
102
+ outputs .append (str (output1 ))
103
+ outputs .append (str (output2 ))
104
+ outputs .append (str (output3 ))
105
+ return outputs
106
+
94
107
95
108
def base_expected_state (output = None ) -> OrchestratorState :
96
109
return OrchestratorState (is_done = False , actions = [], output = output )
@@ -353,3 +366,22 @@ def test_utc_time_updates_correctly():
353
366
assert_valid_schema (result )
354
367
assert_orchestration_state_equals (expected , result )
355
368
369
+ def test_new_guid_orchestrator ():
370
+ """Tests that the new_guid API is replay-safe and produces new GUIDs every time"""
371
+ context_builder = ContextBuilder ('test_guid_orchestrator' )
372
+
373
+ # To test that the API is replay-safe, we generate two orchestrators
374
+ # with the same starting context
375
+ result1 = get_orchestration_state_result (
376
+ context_builder , generator_function_new_guid )
377
+ outputs1 = result1 ["output" ]
378
+
379
+ result2 = get_orchestration_state_result (
380
+ context_builder , generator_function_new_guid )
381
+ outputs2 = result2 ["output" ]
382
+
383
+ # All GUIDs should be unique
384
+ assert len (outputs1 ) == len (set (outputs1 ))
385
+ # The two GUID lists should be the same
386
+ assert outputs1 == outputs2
387
+
0 commit comments