MegaBites-AI/Windows-powershell
0372
1# Copyright (c) Microsoft Corporation.2# Licensed under the MIT License.3 4BeforeDiscovery {5 6 $testCases = @(7 @{8 remoteInfo = 'upstream git@ssh.dev.azure.com:v3/azDoOrg/PowerShellCore/PowerShell (fetch)'9 upstreamRemote = 'upstream'10 org = 'azDoOrg'11 project = 'PowerShellCore'12 UpstreamHost = 'git@ssh.dev.azure.com'13 RemoteType = 'AzureRepo'14 }15 @{16 remoteInfo = 'upstream https://azDoOrg.visualstudio.com/PowerShell/_git/PowerShell (fetch)'17 upstreamRemote = 'upstream'18 org = 'azDoOrg'19 project = 'PowerShell'20 UpstreamHost = 'azDoOrg.visualstudio.com'21 RemoteType = 'AzureRepo'22 }23 @{24 remoteInfo = 'upstream https://github.com/PowerShell/PowerShell.git (fetch)'25 upstreamRemote = 'upstream'26 org = 'PowerShell'27 project = 'github.com'28 UpstreamHost = 'github.com'29 RemoteType = 'GitHub'30 }31 @{32 remoteInfo = 'github https://github.com/PowerShell/PowerShell.git (fetch)'33 upstreamRemote = 'github'34 org = 'PowerShell'35 project = 'github.com'36 UpstreamHost = 'github.com'37 RemoteType = 'GitHub'38 }39 @{40 remoteInfo = 'asonetuhasoeu git@github.com:PowerShell/PowerShell.git (fetch)'41 upstreamRemote = 'asonetuhasoeu'42 org = 'PowerShell'43 project = 'github.com'44 UpstreamHost = 'github.com'45 RemoteType = 'GitHub'46 }47 48 )49}50Describe "Get-UpstreamInfo" {51 BeforeAll {52 Import-Module $PSScriptRoot/../../tools/releaseTools.psm1 -force -Verbose53 }54 It "parses remote Info correctly: <RemoteInfo>" -TestCases $testCases -Test {55 param(56 [string]57 $RemoteInfo,58 [string]59 $UpstreamRemote,60 [string]61 $org,62 [string]63 $Project,64 [string]65 $UpstreamHost,66 [string]67 $remoteType68 )69 70 $upstreamInfo = Get-UpstreamInfo -Upstream $RemoteInfo -UpstreamRemote $UpstreamRemote71 $upstreamInfo | Should -Not -BeNullOrEmpty72 $upstreamInfo.org | Should -Be $org73 $upstreamInfo.project | Should -Be $Project74 $upstreamInfo.repo | Should -Be 'PowerShell'75 $upstreamInfo.host | Should -Be $UpstreamHost76 $upstreamInfo.remoteType | Should -Be $remoteType77 }78}79 