@@ -352,3 +352,149 @@ pub struct PipelineTrigger {
352352 #[ serde( default ) ]
353353 pub branches : Vec < String > ,
354354}
355+
356+ #[ cfg( test) ]
357+ mod tests {
358+ use super :: * ;
359+
360+ // ─── PoolConfig deserialization ──────────────────────────────────────────
361+
362+ #[ test]
363+ fn test_pool_config_string_form ( ) {
364+ let yaml = "pool: MyPool" ;
365+ let fm: serde_yaml:: Value = serde_yaml:: from_str ( yaml) . unwrap ( ) ;
366+ let pool: PoolConfig = serde_yaml:: from_value ( fm[ "pool" ] . clone ( ) ) . unwrap ( ) ;
367+ assert_eq ! ( pool. name( ) , "MyPool" ) ;
368+ assert_eq ! ( pool. os( ) , "linux" ) ; // default
369+ }
370+
371+ #[ test]
372+ fn test_pool_config_object_form_with_os ( ) {
373+ let yaml = "pool:\n name: WinPool\n os: windows" ;
374+ let fm: serde_yaml:: Value = serde_yaml:: from_str ( yaml) . unwrap ( ) ;
375+ let pool: PoolConfig = serde_yaml:: from_value ( fm[ "pool" ] . clone ( ) ) . unwrap ( ) ;
376+ assert_eq ! ( pool. name( ) , "WinPool" ) ;
377+ assert_eq ! ( pool. os( ) , "windows" ) ;
378+ }
379+
380+ #[ test]
381+ fn test_pool_config_object_form_default_os ( ) {
382+ let yaml = "pool:\n name: LinuxPool" ;
383+ let fm: serde_yaml:: Value = serde_yaml:: from_str ( yaml) . unwrap ( ) ;
384+ let pool: PoolConfig = serde_yaml:: from_value ( fm[ "pool" ] . clone ( ) ) . unwrap ( ) ;
385+ assert_eq ! ( pool. name( ) , "LinuxPool" ) ;
386+ assert_eq ! ( pool. os( ) , "linux" ) ;
387+ }
388+
389+ #[ test]
390+ fn test_pool_config_default ( ) {
391+ let pool = PoolConfig :: default ( ) ;
392+ assert_eq ! ( pool. name( ) , "AZS-1ES-L-MMS-ubuntu-22.04" ) ;
393+ assert_eq ! ( pool. os( ) , "linux" ) ;
394+ }
395+
396+ // ─── ScheduleConfig deserialization ─────────────────────────────────────
397+
398+ #[ test]
399+ fn test_schedule_config_simple_has_empty_branches ( ) {
400+ let sc = ScheduleConfig :: Simple ( "daily around 14:00" . to_string ( ) ) ;
401+ assert_eq ! ( sc. expression( ) , "daily around 14:00" ) ;
402+ assert ! ( sc. branches( ) . is_empty( ) ) ;
403+ }
404+
405+ #[ test]
406+ fn test_schedule_config_with_options_returns_branches ( ) {
407+ let yaml = "run: weekly on monday\n branches:\n - main\n - release/*" ;
408+ let opts: ScheduleOptions = serde_yaml:: from_str ( yaml) . unwrap ( ) ;
409+ let sc = ScheduleConfig :: WithOptions ( opts) ;
410+ assert_eq ! ( sc. expression( ) , "weekly on monday" ) ;
411+ assert_eq ! ( sc. branches( ) , & [ "main" , "release/*" ] ) ;
412+ }
413+
414+ #[ test]
415+ fn test_schedule_config_with_options_empty_branches ( ) {
416+ let yaml = "run: hourly" ;
417+ let opts: ScheduleOptions = serde_yaml:: from_str ( yaml) . unwrap ( ) ;
418+ let sc = ScheduleConfig :: WithOptions ( opts) ;
419+ assert_eq ! ( sc. expression( ) , "hourly" ) ;
420+ assert ! ( sc. branches( ) . is_empty( ) ) ;
421+ }
422+
423+ #[ test]
424+ fn test_schedule_config_deserialized_as_simple_string ( ) {
425+ let yaml = "schedule: daily around 14:00" ;
426+ let fm: serde_yaml:: Value = serde_yaml:: from_str ( yaml) . unwrap ( ) ;
427+ let sc: ScheduleConfig = serde_yaml:: from_value ( fm[ "schedule" ] . clone ( ) ) . unwrap ( ) ;
428+ assert_eq ! ( sc. expression( ) , "daily around 14:00" ) ;
429+ assert ! ( sc. branches( ) . is_empty( ) ) ;
430+ }
431+
432+ #[ test]
433+ fn test_schedule_config_deserialized_as_object ( ) {
434+ let yaml = "schedule:\n run: weekly on friday\n branches:\n - main\n - develop" ;
435+ let fm: serde_yaml:: Value = serde_yaml:: from_str ( yaml) . unwrap ( ) ;
436+ let sc: ScheduleConfig = serde_yaml:: from_value ( fm[ "schedule" ] . clone ( ) ) . unwrap ( ) ;
437+ assert_eq ! ( sc. expression( ) , "weekly on friday" ) ;
438+ assert_eq ! ( sc. branches( ) , & [ "main" , "develop" ] ) ;
439+ }
440+
441+ // ─── EngineConfig deserialization ────────────────────────────────────────
442+
443+ #[ test]
444+ fn test_engine_config_simple_string ( ) {
445+ let ec = EngineConfig :: Simple ( "gpt-5.1" . to_string ( ) ) ;
446+ assert_eq ! ( ec. model( ) , "gpt-5.1" ) ;
447+ assert_eq ! ( ec. max_turns( ) , None ) ;
448+ assert_eq ! ( ec. timeout_minutes( ) , None ) ;
449+ }
450+
451+ #[ test]
452+ fn test_engine_config_full_object ( ) {
453+ let yaml = "model: claude-sonnet-4.5\n max-turns: 50\n timeout-minutes: 30" ;
454+ let opts: EngineOptions = serde_yaml:: from_str ( yaml) . unwrap ( ) ;
455+ let ec = EngineConfig :: Full ( opts) ;
456+ assert_eq ! ( ec. model( ) , "claude-sonnet-4.5" ) ;
457+ assert_eq ! ( ec. max_turns( ) , Some ( 50 ) ) ;
458+ assert_eq ! ( ec. timeout_minutes( ) , Some ( 30 ) ) ;
459+ }
460+
461+ #[ test]
462+ fn test_engine_config_full_object_partial_fields ( ) {
463+ let yaml = "max-turns: 10" ;
464+ let opts: EngineOptions = serde_yaml:: from_str ( yaml) . unwrap ( ) ;
465+ let ec = EngineConfig :: Full ( opts) ;
466+ // model defaults to claude-opus-4.5 when not specified
467+ assert_eq ! ( ec. model( ) , "claude-opus-4.5" ) ;
468+ assert_eq ! ( ec. max_turns( ) , Some ( 10 ) ) ;
469+ assert_eq ! ( ec. timeout_minutes( ) , None ) ;
470+ }
471+
472+ #[ test]
473+ fn test_engine_config_default ( ) {
474+ let ec = EngineConfig :: default ( ) ;
475+ assert_eq ! ( ec. model( ) , "claude-opus-4.5" ) ;
476+ assert_eq ! ( ec. max_turns( ) , None ) ;
477+ assert_eq ! ( ec. timeout_minutes( ) , None ) ;
478+ }
479+
480+ #[ test]
481+ fn test_engine_config_deserialized_as_string ( ) {
482+ let yaml = "engine: my-custom-model" ;
483+ let fm: serde_yaml:: Value = serde_yaml:: from_str ( yaml) . unwrap ( ) ;
484+ let ec: EngineConfig = serde_yaml:: from_value ( fm[ "engine" ] . clone ( ) ) . unwrap ( ) ;
485+ assert_eq ! ( ec. model( ) , "my-custom-model" ) ;
486+ assert_eq ! ( ec. max_turns( ) , None ) ;
487+ assert_eq ! ( ec. timeout_minutes( ) , None ) ;
488+ }
489+
490+ #[ test]
491+ fn test_engine_config_deserialized_as_object ( ) {
492+ let yaml =
493+ "engine:\n model: claude-opus-4.5\n max-turns: 50\n timeout-minutes: 30" ;
494+ let fm: serde_yaml:: Value = serde_yaml:: from_str ( yaml) . unwrap ( ) ;
495+ let ec: EngineConfig = serde_yaml:: from_value ( fm[ "engine" ] . clone ( ) ) . unwrap ( ) ;
496+ assert_eq ! ( ec. model( ) , "claude-opus-4.5" ) ;
497+ assert_eq ! ( ec. max_turns( ) , Some ( 50 ) ) ;
498+ assert_eq ! ( ec. timeout_minutes( ) , Some ( 30 ) ) ;
499+ }
500+ }
0 commit comments