File size: 2,560 Bytes
8c763fb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

BeforeDiscovery {

    $testCases = @(
        @{
            remoteInfo = 'upstream	git@ssh.dev.azure.com:v3/azDoOrg/PowerShellCore/PowerShell (fetch)'
            upstreamRemote = 'upstream'
            org = 'azDoOrg'
            project = 'PowerShellCore'
            UpstreamHost = 'git@ssh.dev.azure.com'
            RemoteType = 'AzureRepo'
        }
        @{
            remoteInfo = 'upstream	https://azDoOrg.visualstudio.com/PowerShell/_git/PowerShell (fetch)'
            upstreamRemote = 'upstream'
            org = 'azDoOrg'
            project = 'PowerShell'
            UpstreamHost = 'azDoOrg.visualstudio.com'
            RemoteType = 'AzureRepo'
        }
        @{
            remoteInfo = 'upstream	https://github.com/PowerShell/PowerShell.git (fetch)'
            upstreamRemote = 'upstream'
            org = 'PowerShell'
            project = 'github.com'
            UpstreamHost = 'github.com'
            RemoteType = 'GitHub'
        }
        @{
            remoteInfo = 'github	https://github.com/PowerShell/PowerShell.git (fetch)'
            upstreamRemote = 'github'
            org = 'PowerShell'
            project = 'github.com'
            UpstreamHost = 'github.com'
            RemoteType = 'GitHub'
        }
        @{
            remoteInfo = 'asonetuhasoeu	git@github.com:PowerShell/PowerShell.git (fetch)'
            upstreamRemote = 'asonetuhasoeu'
            org = 'PowerShell'
            project = 'github.com'
            UpstreamHost = 'github.com'
            RemoteType = 'GitHub'
        }

    )
}
Describe "Get-UpstreamInfo" {
    BeforeAll {
        Import-Module $PSScriptRoot/../../tools/releaseTools.psm1 -force -Verbose
    }
    It "parses remote Info correctly: <RemoteInfo>" -TestCases $testCases -Test {
        param(
            [string]
            $RemoteInfo,
            [string]
            $UpstreamRemote,
            [string]
            $org,
            [string]
            $Project,
            [string]
            $UpstreamHost,
            [string]
            $remoteType
        )

        $upstreamInfo = Get-UpstreamInfo -Upstream $RemoteInfo -UpstreamRemote $UpstreamRemote
        $upstreamInfo | Should -Not -BeNullOrEmpty
        $upstreamInfo.org | Should -Be $org
        $upstreamInfo.project | Should -Be $Project
        $upstreamInfo.repo | Should -Be 'PowerShell'
        $upstreamInfo.host | Should -Be $UpstreamHost
        $upstreamInfo.remoteType | Should -Be $remoteType
    }
}