@@ -56,6 +56,73 @@ def test_create_migration_payload_defaults_validate_only_true(self):
5656 payload = mock_send .call_args [0 ][3 ]
5757 self .assertTrue (payload ['validateOnly' ])
5858
59+ def test_create_migration_payload_includes_optional_fields (self ):
60+ with patch ('azext_devops.dev.migration.migration.resolve_instance' ) as mock_resolve , \
61+ patch ('azext_devops.dev.migration.migration._get_service_client' ) as mock_client , \
62+ patch ('azext_devops.dev.migration.migration._send_request' ) as mock_send :
63+ mock_send .return_value = {}
64+ mock_resolve .return_value = self ._TEST_ORG
65+
66+ create_migration (
67+ repository_id = '00000000-0000-0000-0000-000000000000' ,
68+ target_repository = 'https://microsoft.ghe.com/1ES/Gardener' ,
69+ target_owner_user_id = 'GeoffCoxMSFT' ,
70+ validate_only = False ,
71+ scheduled_cutover_date = '2030-12-31T11:59:00Z' ,
72+ agent_pool_name = 'MigrationPool' ,
73+ skip_validation = 'ActivePullRequestCount,PullRequestDeltaSize' ,
74+ organization = self ._TEST_ORG ,
75+ detect = False
76+ )
77+
78+ payload = mock_send .call_args [0 ][3 ]
79+ self .assertFalse (payload ['validateOnly' ])
80+ self .assertEqual (payload ['scheduledCutoverDate' ], '2030-12-31T11:59:00Z' )
81+ self .assertEqual (payload ['agentPoolName' ], 'MigrationPool' )
82+ self .assertEqual (payload ['skipValidation' ], 'ActivePullRequestCount,PullRequestDeltaSize' )
83+
84+ def test_create_migration_omits_empty_optional_fields (self ):
85+ with patch ('azext_devops.dev.migration.migration.resolve_instance' ) as mock_resolve , \
86+ patch ('azext_devops.dev.migration.migration._get_service_client' ) as mock_client , \
87+ patch ('azext_devops.dev.migration.migration._send_request' ) as mock_send :
88+ mock_send .return_value = {}
89+ mock_resolve .return_value = self ._TEST_ORG
90+
91+ create_migration (
92+ repository_id = '00000000-0000-0000-0000-000000000000' ,
93+ target_repository = 'https://microsoft.ghe.com/1ES/Gardener' ,
94+ target_owner_user_id = 'GeoffCoxMSFT' ,
95+ agent_pool_name = ' ' ,
96+ skip_validation = ' ' ,
97+ organization = self ._TEST_ORG ,
98+ detect = False
99+ )
100+
101+ payload = mock_send .call_args [0 ][3 ]
102+ self .assertNotIn ('agentPoolName' , payload )
103+ self .assertNotIn ('skipValidation' , payload )
104+
105+ def test_create_migration_trims_optional_fields (self ):
106+ with patch ('azext_devops.dev.migration.migration.resolve_instance' ) as mock_resolve , \
107+ patch ('azext_devops.dev.migration.migration._get_service_client' ) as mock_client , \
108+ patch ('azext_devops.dev.migration.migration._send_request' ) as mock_send :
109+ mock_send .return_value = {}
110+ mock_resolve .return_value = self ._TEST_ORG
111+
112+ create_migration (
113+ repository_id = '00000000-0000-0000-0000-000000000000' ,
114+ target_repository = 'https://microsoft.ghe.com/1ES/Gardener' ,
115+ target_owner_user_id = 'GeoffCoxMSFT' ,
116+ agent_pool_name = ' MigrationPool ' ,
117+ skip_validation = ' ActivePullRequestCount, PullRequestDeltaSize ' ,
118+ organization = self ._TEST_ORG ,
119+ detect = False
120+ )
121+
122+ payload = mock_send .call_args [0 ][3 ]
123+ self .assertEqual (payload ['agentPoolName' ], 'MigrationPool' )
124+ self .assertEqual (payload ['skipValidation' ], 'ActivePullRequestCount, PullRequestDeltaSize' )
125+
59126 def test_create_migration_rejects_invalid_target_repository (self ):
60127 with self .assertRaises (CLIError ):
61128 create_migration (
0 commit comments