Skip to content

Commit b3743f4

Browse files
committed
Add unit test for parallel script rewire pipeline to include target API URL
1 parent 93ae714 commit b3743f4

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

src/OctoshiftCLI.Tests/ado2gh/Commands/GenerateScript/GenerateScriptCommandHandlerTests.cs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1364,6 +1364,38 @@ public async Task ParallelScript_Rewire_Pipelines_Option_Should_Generate_Share_S
13641364
_scriptOutput.Should().Be(expected.ToString());
13651365
}
13661366

1367+
[Fact]
1368+
public async Task ParallelScript_Rewire_Pipeline_With_TargetApiUrl_Includes_TargetApiUrl()
1369+
{
1370+
// Arrange
1371+
var targetApiUrl = "https://api.tenant.ghe.com";
1372+
1373+
_mockAdoApi.Setup(m => m.GetTeamProjects(ADO_ORG)).ReturnsAsync(ADO_TEAM_PROJECTS);
1374+
_mockAdoApi.Setup(m => m.GetGithubAppId(ADO_ORG, GITHUB_ORG, new[] { ADO_TEAM_PROJECT })).ReturnsAsync(APP_ID);
1375+
1376+
_mockAdoInspector.Setup(m => m.GetRepoCount()).ReturnsAsync(1);
1377+
_mockAdoInspector.Setup(m => m.GetOrgs()).ReturnsAsync(ADO_ORGS);
1378+
_mockAdoInspector.Setup(m => m.GetTeamProjects(ADO_ORG)).ReturnsAsync(ADO_TEAM_PROJECTS);
1379+
_mockAdoInspector.Setup(m => m.GetRepos(ADO_ORG, ADO_TEAM_PROJECT)).ReturnsAsync(ADO_REPOS);
1380+
_mockAdoInspector.Setup(m => m.GetPipelines(ADO_ORG, ADO_TEAM_PROJECT, FOO_REPO)).ReturnsAsync(ADO_PIPELINES);
1381+
1382+
var expectedRewireWithUrl = $"{{ gh ado2gh rewire-pipeline --target-api-url \"{targetApiUrl}\" --ado-org \"{ADO_ORG}\" --ado-team-project \"{ADO_TEAM_PROJECT}\" --ado-pipeline \"{FOO_PIPELINE}\" --github-org \"{GITHUB_ORG}\" --github-repo \"{ADO_TEAM_PROJECT}-{FOO_REPO}\" --service-connection-id \"{APP_ID}\" }}";
1383+
1384+
// Act
1385+
var args = new GenerateScriptCommandArgs
1386+
{
1387+
GithubOrg = GITHUB_ORG,
1388+
AdoOrg = ADO_ORG,
1389+
Output = new FileInfo("unit-test-output"),
1390+
RewirePipelines = true,
1391+
TargetApiUrl = targetApiUrl
1392+
};
1393+
await _handler.Handle(args);
1394+
1395+
// Assert
1396+
_scriptOutput.Should().Contain(expectedRewireWithUrl);
1397+
}
1398+
13671399
[Fact]
13681400
public async Task SequentialScript_CreateTeams_With_TargetApiUrl_Should_Include_TargetApiUrl_In_AddTeamToRepo_Commands()
13691401
{

0 commit comments

Comments
 (0)