-
Notifications
You must be signed in to change notification settings - Fork 25
/
testregex.ps1
53 lines (44 loc) · 1.64 KB
/
testregex.ps1
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
function Get-Account() {
param(
$url
)
$uri = [uri]$url
$hostName = $uri.Host
if (($hostName -eq "dev.azure.com") -or ($hostName -eq "vsrm.dev.azure.com")) {
#new style
$account = $uri.Segments[1].TrimEnd('/') # First segment after hostname
return $account
} elseif ($hostName.EndsWith("visualstudio.com")) {
#old style
$account = $hostName.Split('.')[0] # First subdomain of hostname
return $account
} else {
Write-Host "On-Premise TFS / Azure DevOps Server not supported"
}
}
Describe 'Get Account' {
It 'Uses a Azure DevOps Account' {
$url="https://dev.azure.com/osnabrugge/"
$env:SYSTEM_TEAMFOUNDATIONSERVERURI = $url
$accountReturn = Get-Account -url $url
$accountReturn | Should -Be "osnabrugge"
}
It 'Uses a Azure DevOps Account 2' {
$url="https://vsrm.dev.azure.com/osnabrugge/"
$env:SYSTEM_TEAMFOUNDATIONSERVERURI = $url
$accountReturn = Get-Account -url $url
$accountReturn | Should -Be "osnabrugge"
}
It 'Uses a vs Account' {
$url="https://osnabrugge.visualstudio.com/"
$env:SYSTEM_TEAMFOUNDATIONSERVERURI = $url
$accountReturn = Get-Account -url $url
$accountReturn | Should -Be "osnabrugge"
}
It 'Uses a Azure DevOps Account 2' {
$url="https://osnabrugge.vsrm.visualstudio.com/"
$env:SYSTEM_TEAMFOUNDATIONSERVERURI = $url
$accountReturn = Get-Account -url $url
$accountReturn | Should -Be "osnabrugge"
}
}