@@ -275,3 +275,103 @@ def test_workflow_commands(postgres_db_engine: sa.Engine) -> None:
275275 assert isinstance (fork_wf_data , dict )
276276 assert fork_wf_data ["workflow_id" ] != wf_id
277277 assert fork_wf_data ["status" ] == "ENQUEUED"
278+
279+ # fork the workflow with custom forked workflow ID
280+ custom_fork_id = "custom-fork-id-12345"
281+ output = subprocess .check_output (
282+ [
283+ "dbos" ,
284+ "workflow" ,
285+ "fork" ,
286+ wf_id ,
287+ "--step" ,
288+ "3" ,
289+ "--forked-workflow-id" ,
290+ custom_fork_id ,
291+ ],
292+ cwd = temp_path ,
293+ env = env ,
294+ )
295+ custom_fork_data = json .loads (output )
296+ assert isinstance (custom_fork_data , dict )
297+ assert custom_fork_data ["workflow_id" ] == custom_fork_id
298+ assert custom_fork_data ["status" ] == "ENQUEUED"
299+
300+ # verify the forked workflow data with get command
301+ output = subprocess .check_output (
302+ ["dbos" , "workflow" , "get" , custom_fork_id , "--db-url" , db_url ],
303+ cwd = temp_path ,
304+ )
305+ custom_fork_get_data = json .loads (output )
306+ assert isinstance (custom_fork_get_data , dict )
307+ assert custom_fork_get_data ["workflow_id" ] == custom_fork_id
308+
309+ # fork the workflow with custom application version
310+ output = subprocess .check_output (
311+ [
312+ "dbos" ,
313+ "workflow" ,
314+ "fork" ,
315+ wf_id ,
316+ "--step" ,
317+ "2" ,
318+ "--application-version" ,
319+ "test-version" ,
320+ ],
321+ cwd = temp_path ,
322+ env = env ,
323+ )
324+ version_fork_data = json .loads (output )
325+ assert isinstance (version_fork_data , dict )
326+ assert version_fork_data ["workflow_id" ] != wf_id
327+ assert version_fork_data ["status" ] == "ENQUEUED"
328+
329+ # verify the forked workflow data with get command and check application version
330+ output = subprocess .check_output (
331+ [
332+ "dbos" ,
333+ "workflow" ,
334+ "get" ,
335+ version_fork_data ["workflow_id" ],
336+ "--db-url" ,
337+ db_url ,
338+ ],
339+ cwd = temp_path ,
340+ )
341+ version_fork_get_data = json .loads (output )
342+ assert isinstance (version_fork_get_data , dict )
343+ assert version_fork_get_data ["workflow_id" ] == version_fork_data ["workflow_id" ]
344+ assert version_fork_get_data ["app_version" ] == "test-version"
345+
346+ # fork the workflow with both custom ID and application version
347+ custom_fork_id2 = "custom-fork-with-version-67890"
348+ output = subprocess .check_output (
349+ [
350+ "dbos" ,
351+ "workflow" ,
352+ "fork" ,
353+ wf_id ,
354+ "--step" ,
355+ "4" ,
356+ "--forked-workflow-id" ,
357+ custom_fork_id2 ,
358+ "--application-version" ,
359+ "v2.0.0" ,
360+ ],
361+ cwd = temp_path ,
362+ env = env ,
363+ )
364+ combined_fork_data = json .loads (output )
365+ assert isinstance (combined_fork_data , dict )
366+ assert combined_fork_data ["workflow_id" ] == custom_fork_id2
367+ assert combined_fork_data ["status" ] == "ENQUEUED"
368+
369+ # verify the forked workflow data with get command and check both ID and application version
370+ output = subprocess .check_output (
371+ ["dbos" , "workflow" , "get" , custom_fork_id2 , "--db-url" , db_url ],
372+ cwd = temp_path ,
373+ )
374+ combined_fork_get_data = json .loads (output )
375+ assert isinstance (combined_fork_get_data , dict )
376+ assert combined_fork_get_data ["workflow_id" ] == custom_fork_id2
377+ assert combined_fork_get_data ["app_version" ] == "v2.0.0"
0 commit comments