diff --git a/.docs/Update-VSTeamServiceEndpoint.md b/.docs/Update-VSTeamServiceEndpoint.md
index b62a87463..3110e4377 100644
--- a/.docs/Update-VSTeamServiceEndpoint.md
+++ b/.docs/Update-VSTeamServiceEndpoint.md
@@ -37,6 +37,8 @@ Required: true
Accept pipeline input: true (ByPropertyName)
```
+
+
## INPUTS
## OUTPUTS
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d5a86e783..4ba44d441 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,24 @@
# Changelog
+## 4.0.0
+
+**Breaking changes**:
+The @VSTeamVersionTable was removed and replaced with a static VSTeamVersions class. This allows the values to flow between the provider and the rest of the functions in the module.
+
+Due to this breaking change _Get-VSTeamAPIVersion_ was added to review the current version being used.
+
+Merged [Pull Request](https://github.com/DarqueWarrior/vsteam/pull/77) from [Kai Walter](https://github.com/KaiWalter) which included the following:
+
+Build Definition / Process / Phases / Steps are broken down into separate objects
+
+```PowerShell
+(Get-VSTeamBuildDefinition -ProjectName MyProject -Id 42).Process
+(Get-VSTeamBuildDefinition -ProjectName MyProject -Id 42).Process.Phases
+(Get-VSTeamBuildDefinition -ProjectName MyProject -Id 42).Process.Phases[0].Steps
+(Get-VSTeamBuildDefinition -ProjectName MyProject -Id 42).Process.Phases[0].Steps[0]
+```
+
+
## 3.0.7
Removed some common code and took dependency on Trackyon.Utils that did the same things.
@@ -243,7 +262,7 @@ You can now tab complete your profiles.
Added support for Profiles. Now you can store different accounts and PATS as a profile using Add-VSTeamProfile. Then you can call Add-VSTeamAccount with the -Profile parameter and the PAT will be read from the profile. This prevents you having to remember the PAT to switch between accounts. Profiles also store the API version to use with the account.
-Added $VSTeamVersionTable so you can experiment with different versions of the VSTS/TFS APIs. The variable contains the following:
+Added $Global:VSTeamVersionTable so you can experiment with different versions of the VSTS/TFS APIs. The variable contains the following:
- 'Build' = '3.0'
- 'Release' = '3.0-preview'
diff --git a/VSTeam.psd1 b/VSTeam.psd1
index e39d34f48..e480fc918 100644
--- a/VSTeam.psd1
+++ b/VSTeam.psd1
@@ -13,7 +13,7 @@
RootModule = ''
# Version number of this module.
- ModuleVersion = '3.0.7'
+ ModuleVersion = '4.0.0'
# Supported PSEditions
# CompatiblePSEditions = @()
@@ -62,7 +62,6 @@
# Type files (.ps1xml) to be loaded when importing this module
TypesToProcess = @('types\Approvals.ps1xml',
- 'types\buildDefinitions.ps1xml',
'types\builds.ps1xml',
'types\cloudSubscriptions.ps1xml',
'types\repositories.ps1xml',
@@ -80,7 +79,6 @@
# Format files (.ps1xml) to be loaded when importing this module
FormatsToProcess = @('formats\Approvals.format.ps1xml',
- 'formats\buildDefinitions.format.ps1xml',
'formats\builds.format.ps1xml',
'formats\policyTypes.format.ps1xml',
'formats\profile.format.ps1xml',
@@ -206,7 +204,8 @@
'Remove-VSTeamAgent',
'Enable-VSTeamAgent',
'Disable-VSTeamAgent',
- 'Update-VSTeamProfile')
+ 'Update-VSTeamProfile',
+ 'Get-VSTeamAPIVersion')
# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
# CmdletsToExport = @()
@@ -310,7 +309,8 @@
'Remove-Agent',
'Enable-Agent',
'Disable-Agent',
- 'Update-Profile')
+ 'Update-Profile',
+ 'Get-APIVersion')
# DSC resources to export from this module
# DscResourcesToExport = @()
diff --git a/docs/Update-VSTeamServiceEndpoint.md b/docs/Update-VSTeamServiceEndpoint.md
index 579bc5d5f..b8707aa4b 100644
--- a/docs/Update-VSTeamServiceEndpoint.md
+++ b/docs/Update-VSTeamServiceEndpoint.md
@@ -52,6 +52,14 @@ Required: true
Accept pipeline input: true (ByPropertyName)
```
+### -Force
+
+Forces the command without confirmation
+
+```yaml
+Type: SwitchParameter
+```
+
## INPUTS
## OUTPUTS
diff --git a/en-US/VSTeam-Help.xml b/en-US/VSTeam-Help.xml
index b14696420..aad8ac5a1 100644
--- a/en-US/VSTeam-Help.xml
+++ b/en-US/VSTeam-Help.xml
@@ -13480,6 +13480,17 @@ Demo-CI Demo-CI-45 notStarted
None
+
+ Force
+
+ Forces the command without confirmation
+
+
+ SwitchParameter
+
+
+ False
+
@@ -13521,6 +13532,18 @@ Demo-CI Demo-CI-45 notStarted
None
+
+ Force
+
+ Forces the command without confirmation
+
+ SwitchParameter
+
+ SwitchParameter
+
+
+ False
+
diff --git a/en-US/about_vsteam.help.txt b/en-US/about_vsteam.help.txt
index 3a297f246..2812d6999 100644
--- a/en-US/about_vsteam.help.txt
+++ b/en-US/about_vsteam.help.txt
@@ -14,9 +14,9 @@ LONG DESCRIPTION
-ProjectName parameter is dynamic and you can use tab completion to cycle
through all the projects.
- Using the $VSTeamVersionTable variable you can control which version of the APIs are used.
+ Using the [VSTeamVersions] class you can control which version of the APIs are used.
- PS C:\> $VSTeamVersionTable
+ PS C:\> Get-VSTeamAPIVersion
Name Value
---- -----
@@ -52,7 +52,7 @@ LONG DESCRIPTION
To use different API versions you can update the version in the version table.
- PS C:\> $VSTeamVersionTable.Build = '4.0'
+ PS C:\> [VSTeamVersions]::Build = '4.0'
You can also use Set-VSTeamAPIVersion to set all the API versions for either
TFS2017, TFS2018 or VSTS. TFS2017 is the default.
diff --git a/formats/buildDefinitions.format.ps1xml b/formats/buildDefinitions.format.ps1xml
deleted file mode 100644
index 1f8663dc8..000000000
--- a/formats/buildDefinitions.format.ps1xml
+++ /dev/null
@@ -1,45 +0,0 @@
-
-
-
-
- Team.BuildDefinition.TableView
-
- Team.BuildDefinition
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- id
-
-
- authoredByUser
-
-
- queueName
-
-
- fullname
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/formats/vsteamPSDrive.format.ps1xml b/formats/vsteamPSDrive.format.ps1xml
index 571910472..6c1ccc21e 100644
--- a/formats/vsteamPSDrive.format.ps1xml
+++ b/formats/vsteamPSDrive.format.ps1xml
@@ -47,7 +47,7 @@
-
+
RefTable
Team.GitRef
@@ -80,7 +80,7 @@
-
+
Team.Agent.Table
Team.Agent
@@ -129,8 +129,8 @@
-
-
+
+
Team.Provider.Agent.Table
Team.Provider.Agent
@@ -278,7 +278,7 @@
-
+
StatusTable
Team.Provider.Release
@@ -447,6 +447,406 @@
+
+
+ Team.BuildDefinition.Table
+
+ Team.BuildDefinition
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Name
+
+
+ ID
+
+
+
+
+
+
+
+
+
+ Team.BuildDefinition.Table
+
+ Team.Provider.BuildDefinition
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ DisplayMode
+
+
+ Name
+
+
+ ID
+
+
+
+
+
+
+
+
+
+ Team.BuildDefinition.List
+
+ Team.BuildDefinition
+
+
+
+
+
+
+ ID
+
+
+ Name
+
+
+ AuthoredBy
+
+
+
+
+
+
+
+
+
+ Team.BuildDefinitionYamlProcess.Table
+
+ Team.BuildDefinitionYamlProcess
+
+
+
+
+
+
+
+
+
+
+
+
+
+ yamlFilename
+
+
+
+
+
+
+
+
+
+ Team.Provider.BuildDefinitionYamlProcess.Table
+
+ Team.Provider.BuildDefinitionYamlProcess
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ DisplayMode
+
+
+ yamlFilename
+
+
+
+
+
+
+
+
+
+ Team.BuildDefinitionPhasedProcess.Table
+
+ Team.BuildDefinitionPhasedProcess
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Name
+
+
+ Phases
+
+
+
+
+
+
+
+
+
+ Team.BuildDefinitionProcess.List
+
+ Team.BuildDefinitionProcess
+
+
+
+
+
+
+ Name
+
+
+ Phases
+
+
+
+
+
+
+
+
+
+ Team.BuildDefinitionProcessPhase.Table
+
+ Team.BuildDefinitionProcessPhase
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Name
+
+
+ StepCount
+
+
+
+
+
+
+
+
+
+ Team.Provider.BuildDefinitionProcessPhase.Table
+
+ Team.Provider.BuildDefinitionProcessPhase
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ DisplayMode
+
+
+ Name
+
+
+ StepCount
+
+
+
+
+
+
+
+
+
+ Team.BuildDefinitionProcessPhase.List
+
+ Team.BuildDefinitionProcessPhase
+
+
+
+
+
+
+ Name
+
+
+ Steps
+
+
+
+
+
+
+
+
+
+ Team.BuildDefinitionProcessPhaseStep.Table
+
+ Team.BuildDefinitionProcessPhaseStep
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ID
+
+
+ Name
+
+
+ Enabled
+
+
+
+
+
+
+
+
+
+ Team.Provider.BuildDefinitionProcessPhaseStep.Table
+
+ Team.Provider.BuildDefinitionProcessPhaseStep
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ DisplayMode
+
+
+ Name
+
+
+ Enabled
+
+
+
+
+
+
+
+
+
+ Team.BuildDefinitionProcessPhaseStep.List
+
+ Team.BuildDefinitionProcessPhaseStep
+
+
+
+
+
+
+ ID
+
+
+ Name
+
+
+ Enabled
+
+
+
+
+
+
+
ReleaseTable
@@ -526,7 +926,6 @@
-
Team.Provider.RepositoryTable
@@ -791,6 +1190,7 @@
Team.Pools
Team.Provider.Pools
Team.Builds
+ Team.BuildDefinitions
Team.Releases
Team.Repositories
Team.Teams
@@ -830,6 +1230,7 @@
Team.Pool
Team.Pools
Team.Builds
+ Team.BuildDefinitions
Team.Releases
Team.Repositories
Team.Teams
diff --git a/integration/test/000_team.Tests.ps1 b/integration/test/000_team.Tests.ps1
index b52db5daf..b38c396e7 100644
--- a/integration/test/000_team.Tests.ps1
+++ b/integration/test/000_team.Tests.ps1
@@ -34,7 +34,7 @@ Describe 'Team' -Tag 'integration' {
Context 'Get-VSTeamInfo' {
It 'should return account and default project' {
- $VSTeamVersionTable.Account = "mydemos"
+ [VSTeamVersions]::Account = "mydemos"
$Global:PSDefaultParameterValues['*:projectName'] = 'MyProject'
$info = Get-VSTeamInfo
diff --git a/integration/test/010_projects.Tests.ps1 b/integration/test/010_projects.Tests.ps1
index 90159fe21..341fc4e35 100644
--- a/integration/test/010_projects.Tests.ps1
+++ b/integration/test/010_projects.Tests.ps1
@@ -205,13 +205,20 @@ Describe 'VSTeam Integration Tests' -Tag 'integration' {
# Only run for VSTS
if ($api -eq 'VSTS') {
- It 'Get-VSTeamBuildDefinition by Id should return 1 phase for 1st build definition' {
- $buildDefId = (Get-VSTeamBuildDefinition -ProjectName $newProjectName | Where-Object {$_.Name -like "*CI1"}).Id
- ((Get-VSTeamBuildDefinition -ProjectName $newProjectName -Id $buildDefId).Process.Phases).Count | Should Be 1
+ It 'Get-VSTeamBuildDefinition by Id should return intended attribute values for 1st build definition' {
+ $buildDefId = (Get-VSTeamBuildDefinition -ProjectName $newProjectName | Where-Object {$_.Name -eq $($newProjectName + "-CI1")}).Id
+ $buildDefId | Should Not Be $null
+ $buildDef = Get-VSTeamBuildDefinition -ProjectName $newProjectName -Id $buildDefId
+ $buildDef.Name | Should Be $($newProjectName + "-CI1")
+ $buildDef.Process.Phases.Count | Should Be 1
+ $buildDef.Process.Phases[0].Name | Should Be "Phase 1"
+ $buildDef.Process.Phases[0].Steps.Count | Should Be 1
+ $buildDef.Process.Phases[0].Steps[0].Name | Should Be "PowerShell Script"
+ $buildDef.Process.Phases[0].Steps[0].Inputs.targetType | Should Be "inline"
}
- It 'Get-VSTeamBuildDefinition by Id should return 2 phase for 2nd build definition' {
- $buildDefId = (Get-VSTeamBuildDefinition -ProjectName $newProjectName | Where-Object {$_.Name -like "*CI2"}).Id
+ It 'Get-VSTeamBuildDefinition by Id should return 2 phases for 2nd build definition' {
+ $buildDefId = (Get-VSTeamBuildDefinition -ProjectName $newProjectName | Where-Object {$_.Name -eq $($newProjectName + "-CI2")}).Id
((Get-VSTeamBuildDefinition -ProjectName $newProjectName -Id $buildDefId).Process.Phases).Count | Should Be 2
}
}
@@ -238,7 +245,14 @@ Describe 'VSTeam Integration Tests' -Tag 'integration' {
Context 'Agent full exercise' {
It 'Get-VSTeamAgent Should return agents' {
- $pool = (Get-VSTeamPool)[0]
+ if ($acct -like "http://*") {
+ $pool = (Get-VSTeamPool)[0]
+ }
+ else {
+ # Grabbing the first hosted pool on VSTS. Skipping index 0 which is
+ # default and is empty on some accounts
+ $pool = (Get-VSTeamPool)[1]
+ }
$actual = Get-VSTeamAgent -PoolId $pool.Id
$actual | Should Not Be $null
@@ -389,13 +403,13 @@ Describe 'VSTeam Integration Tests' -Tag 'integration' {
It 'Set-VSTeamAPIVersion to TFS2018' {
Set-VSTeamAPIVersion TFS2018
- $VSTeamVersionTable.Version | Should Be 'TFS2018'
+ [VSTeamVersions]::Version | Should Be 'TFS2018'
}
It 'Set-VSTeamAPIVersion to TFS2017' {
Set-VSTeamAPIVersion TFS2017
- $VSTeamVersionTable.Version | Should Be 'TFS2017'
+ [VSTeamVersions]::Version | Should Be 'TFS2017'
}
It 'Clear-VSTeamDefaultProject should clear project' {
diff --git a/src/Approvals.psm1 b/src/Approvals.psm1
index 613d75ee8..cf64d4555 100644
--- a/src/Approvals.psm1
+++ b/src/Approvals.psm1
@@ -37,23 +37,24 @@ function Get-VSTeamApproval {
$queryString = @{statusFilter = $StatusFilter; assignedtoFilter = $AssignedToFilter; releaseIdsFilter = ($ReleaseIdsFilter -join ',')}
# The support in TFS and VSTS are not the same.
- if (_isVSTS $VSTeamVersionTable.Account) {
- if ($AssignedToFilter -ne $null -and $AssignedToFilter -ne "") {
+ $instance = $([VSTeamVersions]::Account)
+ if (_isVSTS $instance) {
+ if ([string]::IsNullOrEmpty($AssignedToFilter) -eq $false) {
$queryString.includeMyGroupApprovals = 'true';
}
}
else {
# For TFS all three parameters must be set before you can add
# includeMyGroupApprovals.
- if ($AssignedToFilter -ne $null -and $AssignedToFilter -ne "" -and
- $ReleaseIdsFilter -ne $null -and $ReleaseIdsFilter -ne "" -and
+ if ([string]::IsNullOrEmpty($AssignedToFilter) -eq $false -and
+ [string]::IsNullOrEmpty($ReleaseIdsFilter) -eq $false -and
$StatusFilter -eq 'Pending') {
$queryString.includeMyGroupApprovals = 'true';
}
}
# Call the REST API
- $resp = _callAPI -ProjectName $ProjectName -Area release -Resource approvals -SubDomain vsrm -Version $VSTeamVersionTable.Release -QueryString $queryString
+ $resp = _callAPI -ProjectName $ProjectName -Area release -Resource approvals -SubDomain vsrm -Version $([VSTeamVersions]::Release) -QueryString $queryString
# Apply a Type Name so we can use custom format view and custom type extensions
foreach ($item in $resp.value) {
@@ -86,7 +87,7 @@ function Show-VSTeamApproval {
# Bind the parameter to a friendly variable
$ProjectName = $PSBoundParameters["ProjectName"]
- Show-Browser "$($VSTeamVersionTable.Account)/$ProjectName/_release?releaseId=$ReleaseDefinitionId"
+ Show-Browser "$([VSTeamVersions]::Account)/$ProjectName/_release?releaseId=$ReleaseDefinitionId"
}
}
@@ -128,7 +129,7 @@ function Set-VSTeamApproval {
try {
# Call the REST API
_callAPI -Method Patch -SubDomain vsrm -ProjectName $ProjectName -Area release -Resource approvals `
- -Id $item -Version $VSTeamVersionTable.Release -body $body -ContentType 'application/json' | Out-Null
+ -Id $item -Version $([VSTeamVersions]::Release) -body $body -ContentType 'application/json' | Out-Null
Write-Output "Approval $item status changed to $status"
}
diff --git a/src/agents.psm1 b/src/agents.psm1
index fe6bb0cd4..904d9c6e5 100644
--- a/src/agents.psm1
+++ b/src/agents.psm1
@@ -19,7 +19,7 @@ function Get-VSTeamAgent {
if ($id) {
$resp = _callAPI -Area "distributedtask/pools/$PoolId" -Resource agents -Id $id `
- -Body @{includeCapabilities = 'true'} -Version $VSTeamVersionTable.DistributedTask
+ -Body @{includeCapabilities = 'true'} -Version $([VSTeamVersions]::DistributedTask)
# Storing the object before you return it cleaned up the pipeline.
# When I just write the object from the constructor each property
@@ -30,7 +30,7 @@ function Get-VSTeamAgent {
}
else {
$resp = _callAPI -Area "distributedtask/pools/$PoolId" -Resource agents `
- -Body @{includeCapabilities = 'true'} -Version $VSTeamVersionTable.DistributedTask
+ -Body @{includeCapabilities = 'true'} -Version $([VSTeamVersions]::DistributedTask)
$objs = @()
@@ -61,7 +61,7 @@ function Remove-VSTeamAgent {
foreach ($item in $Id) {
if ($force -or $pscmdlet.ShouldProcess($item,"Delete agent")) {
try {
- _callAPI -Method Delete -Area "distributedtask/pools/$PoolId" -Resource agents -Id $item -Version $VSTeamVersionTable.DistributedTask | Out-Null
+ _callAPI -Method Delete -Area "distributedtask/pools/$PoolId" -Resource agents -Id $item -Version $([VSTeamVersions]::DistributedTask) | Out-Null
Write-Output "Deleted agent $item"
}
catch {
@@ -85,7 +85,7 @@ function Enable-VSTeamAgent {
process {
foreach ($item in $Id) {
try {
- _callAPI -Method Patch -Area "distributedtask/pools/$PoolId" -Resource agents -Id $item -Version $VSTeamVersionTable.DistributedTask -ContentType "application/json" -Body "{'enabled':true,'id':$item}" | Out-Null
+ _callAPI -Method Patch -Area "distributedtask/pools/$PoolId" -Resource agents -Id $item -Version $([VSTeamVersions]::DistributedTask) -ContentType "application/json" -Body "{'enabled':true,'id':$item}" | Out-Null
Write-Output "Enabled agent $item"
}
catch {
@@ -108,7 +108,7 @@ function Disable-VSTeamAgent {
process {
foreach ($item in $Id) {
try {
- _callAPI -Method Patch -Area "distributedtask/pools/$PoolId" -Resource agents -Id $item -Version $VSTeamVersionTable.DistributedTask -ContentType "application/json" -Body "{'enabled':false,'id':$item}" | Out-Null
+ _callAPI -Method Patch -Area "distributedtask/pools/$PoolId" -Resource agents -Id $item -Version $([VSTeamVersions]::DistributedTask) -ContentType "application/json" -Body "{'enabled':false,'id':$item}" | Out-Null
Write-Output "Disabled agent $item"
}
catch {
diff --git a/src/buildDefinitions.psm1 b/src/buildDefinitions.psm1
index c02108a11..df9be79cb 100644
--- a/src/buildDefinitions.psm1
+++ b/src/buildDefinitions.psm1
@@ -4,37 +4,6 @@ Set-StrictMode -Version Latest
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
. "$here\common.ps1"
-# Apply types to the returned objects so format and type files can
-# identify the object and act on it.
-function _applyTypesToBuildDefinition {
- param($item)
-
- $item.PSObject.TypeNames.Insert(0, 'Team.BuildDefinition')
-
- $item.project.PSObject.TypeNames.Insert(0, 'Team.Project')
-
- if ($item.PSObject.Properties.Match('authoredBy').count -gt 0 -and $null -ne $item.authoredBy) {
- $item.authoredBy.PSObject.TypeNames.Insert(0, 'Team.User')
- }
-
- if ($item.PSObject.Properties.Match('_links').count -gt 0 -and $null -ne $item._links) {
- $item._links.PSObject.TypeNames.Insert(0, 'Team.Links')
- }
-
- if ($item.PSObject.Properties.Match('queue').count -gt 0 -and $null -ne $item.queue) {
- $item.queue.PSObject.TypeNames.Insert(0, 'Team.Queue')
- }
-
- # Only returned for a single item
- if ($item.PSObject.Properties.Match('variables').count -gt 0 -and $null -ne $item.variables) {
- $item.variables.PSObject.TypeNames.Insert(0, 'Team.Variables')
- }
-
- if ($item.PSObject.Properties.Match('repository').count -gt 0 -and $null -ne $item.repository) {
- $item.repository.PSObject.TypeNames.Insert(0, 'Team.Repository')
- }
-}
-
function Get-VSTeamBuildDefinition {
[CmdletBinding(DefaultParameterSetName = 'List')]
param(
@@ -45,7 +14,7 @@ function Get-VSTeamBuildDefinition {
[ValidateSet('build', 'xaml', 'All')]
[string] $Type = 'All',
- [Parameter(ParameterSetName = 'ByID', Mandatory = $true, ValueFromPipelineByPropertyName = $true)]
+ [Parameter(ParameterSetName = 'ByID', Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
[Alias('BuildDefinitionID')]
[int[]] $Id,
@@ -60,27 +29,30 @@ function Get-VSTeamBuildDefinition {
process {
# Bind the parameter to a friendly variable
$ProjectName = $PSBoundParameters["ProjectName"]
-
+
if ($id) {
foreach ($item in $id) {
- $resp = _callAPI -ProjectName $ProjectName -Id $item -Area build -Resource definitions -Version $VSTeamVersionTable.Build `
+ $resp = _callAPI -ProjectName $ProjectName -Id $item -Area build -Resource definitions -Version $([VSTeamVersions]::Build) `
-QueryString @{revision = $revision}
- _applyTypesToBuildDefinition -item $resp
+ Write-Verbose $resp
+ $item = [VSTeamBuildDefinition]::new($resp, $ProjectName)
- Write-Output $resp
+ Write-Output $item
}
}
else {
- $resp = _callAPI -ProjectName $ProjectName -Area build -Resource definitions -Version $VSTeamVersionTable.Build `
- -QueryString @{type = $type; name = $filter}
+ $resp = _callAPI -ProjectName $ProjectName -Area build -Resource definitions -Version $([VSTeamVersions]::Build) `
+ -QueryString @{type = $type; name = $filter; includeAllProperties = $true}
- # Apply a Type Name so we can use custom format view and custom type extensions
+ $objs = @()
+
foreach ($item in $resp.value) {
- _applyTypesToBuildDefinition -item $item
+ Write-Verbose $item
+ $objs += [VSTeamBuildDefinition]::new($item, $ProjectName)
}
-
- Write-Output $resp.value
+
+ Write-Output $objs
}
}
}
@@ -112,7 +84,7 @@ function Show-VSTeamBuildDefinition {
$ProjectName = $PSBoundParameters["ProjectName"]
# Build the url
- $url = "$($VSTeamVersionTable.Account)/$ProjectName/_build"
+ $url = "$([VSTeamVersions]::Account)/$ProjectName/_build"
if ($id) {
$url += "/index?definitionId=$id"
@@ -161,7 +133,7 @@ function Add-VSTeamBuildDefinition {
# Bind the parameter to a friendly variable
$ProjectName = $PSBoundParameters["ProjectName"]
- $resp = _callAPI -Method Post -ProjectName $ProjectName -Area build -Resource definitions -Version $VSTeamVersionTable.Build -infile $InFile -ContentType 'application/json'
+ $resp = _callAPI -Method Post -ProjectName $ProjectName -Area build -Resource definitions -Version $([VSTeamVersions]::Build) -infile $InFile -ContentType 'application/json'
return $resp
}
@@ -188,7 +160,7 @@ function Remove-VSTeamBuildDefinition {
foreach ($item in $id) {
if ($Force -or $pscmdlet.ShouldProcess($item, "Delete Build Definition")) {
# Call the REST API
- _callAPI -Method Delete -ProjectName $ProjectName -Area build -Resource definitions -Id $item -Version $VSTeamVersionTable.Build | Out-Null
+ _callAPI -Method Delete -ProjectName $ProjectName -Area build -Resource definitions -Id $item -Version $([VSTeamVersions]::Build) | Out-Null
Write-Output "Deleted build defintion $item"
}
@@ -219,7 +191,7 @@ function Update-VSTeamBuildDefinition {
if ($Force -or $pscmdlet.ShouldProcess($Id, "Update Build Definition")) {
# Call the REST API
- _callAPI -Method Put -ProjectName $ProjectName -Area build -Resource definitions -Id $Id -Version $VSTeamVersionTable.Build -InFile $InFile -ContentType 'application/json' | Out-Null
+ _callAPI -Method Put -ProjectName $ProjectName -Area build -Resource definitions -Id $Id -Version $([VSTeamVersions]::Build) -InFile $InFile -ContentType 'application/json' | Out-Null
}
}
}
diff --git a/src/builds.psm1 b/src/builds.psm1
index d6cefc2ac..6bb3a71ac 100644
--- a/src/builds.psm1
+++ b/src/builds.psm1
@@ -91,7 +91,7 @@ function Get-VSTeamBuild {
foreach ($item in $id) {
# Build the url to return the single build
$resp = _callAPI -ProjectName $projectName -Area 'build' -Resource 'builds' -id $item `
- -Version $VSTeamVersionTable.Build
+ -Version $([VSTeamVersions]::Build)
_applyTypesToBuild -item $resp
@@ -101,7 +101,7 @@ function Get-VSTeamBuild {
else {
# Build the url to list the builds
$resp = _callAPI -ProjectName $projectName -Area 'build' -Resource 'builds' `
- -Version $VSTeamVersionTable.Build `
+ -Version $([VSTeamVersions]::Build) `
-Querystring @{
'$top' = $top
'type' = $type
@@ -141,7 +141,7 @@ function Show-VSTeamBuild {
# Bind the parameter to a friendly variable
$ProjectName = $PSBoundParameters["ProjectName"]
- Show-Browser "$($VSTeamVersionTable.Account)/$ProjectName/_build/index?buildId=$Id"
+ Show-Browser "$([VSTeamVersions]::Account)/$ProjectName/_build/index?buildId=$Id"
}
}
@@ -167,7 +167,7 @@ function Get-VSTeamBuildLog {
# Build the url to return the logs of the build
# Call the REST API to get the number of logs for the build
$resp = _callAPI -ProjectName $projectName -Area 'build' -Resource "builds/$item/logs" `
- -Version $VSTeamVersionTable.Build
+ -Version $([VSTeamVersions]::Build)
$fullLogIndex = $($resp.count - 1)
}
@@ -179,7 +179,7 @@ function Get-VSTeamBuildLog {
# Build the url to return the single build
# Call the REST API to get the number of logs for the build
$resp = _callAPI -ProjectName $projectName -Area 'build' -Resource "builds/$item/logs" -id $fullLogIndex `
- -Version $VSTeamVersionTable.Build
+ -Version $([VSTeamVersions]::Build)
Write-Output $resp
}
@@ -275,7 +275,7 @@ function Add-VSTeamBuild {
# Call the REST API
$resp = _callAPI -ProjectName $ProjectName -Area 'build' -Resource 'builds' `
-Method Post -ContentType 'application/json' -Body ($body | ConvertTo-Json) `
- -Version $VSTeamVersionTable.Build
+ -Version $([VSTeamVersions]::Build)
_applyTypesToBuild -item $resp
@@ -305,7 +305,7 @@ function Remove-VSTeamBuild {
if ($Force -or $pscmdlet.ShouldProcess($item, "Delete Build")) {
try {
_callAPI -ProjectName $ProjectName -Area 'build' -Resource 'builds' -id $item `
- -Method Delete -Version $VSTeamVersionTable.Build | Out-Null
+ -Method Delete -Version $([VSTeamVersions]::Build) | Out-Null
Write-Output "Deleted build $item"
}
@@ -362,7 +362,7 @@ function Update-VSTeamBuild {
# Call the REST API
_callAPI -ProjectName $ProjectName -Area 'build' -Resource 'builds' -Id $Id `
- -Method Patch -ContentType 'application/json' -body $body -Version $VSTeamVersionTable.Build | Out-Null
+ -Method Patch -ContentType 'application/json' -body $body -Version $([VSTeamVersions]::Build) | Out-Null
}
}
}
@@ -383,7 +383,7 @@ function Get-VSTeamBuildTag {
# Call the REST API
$resp = _callAPI -ProjectName $projectName -Area 'build' -Resource "builds/$Id/tags" `
- -Version $VSTeamVersionTable.Build
+ -Version $([VSTeamVersions]::Build)
return $resp.value
}
@@ -414,7 +414,7 @@ function Add-VSTeamBuildTag {
foreach ($tag in $tags) {
# Call the REST API
_callAPI -ProjectName $projectName -Area 'build' -Resource "builds/$Id/tags" `
- -Method Put -Querystring @{tag = $tag} -Version $VSTeamVersionTable.Build | Out-Null
+ -Method Put -Querystring @{tag = $tag} -Version $([VSTeamVersions]::Build) | Out-Null
}
}
}
@@ -446,7 +446,7 @@ function Remove-VSTeamBuildTag {
foreach ($tag in $tags) {
# Call the REST API
_callAPI -ProjectName $projectName -Area 'build' -Resource "builds/$Id/tags" `
- -Method Delete -Querystring @{tag = $tag} -Version $VSTeamVersionTable.Build | Out-Null
+ -Method Delete -Querystring @{tag = $tag} -Version $([VSTeamVersions]::Build) | Out-Null
}
}
}
@@ -468,7 +468,7 @@ function Get-VSTeamBuildArtifact {
$ProjectName = $PSBoundParameters["ProjectName"]
$resp = _callAPI -ProjectName $projectName -Area 'build' -Resource "builds/$Id/artifacts" `
- -Version $VSTeamVersionTable.Build
+ -Version $([VSTeamVersions]::Build)
foreach ($item in $resp.value) {
_applyArtifactTypes -item $item
diff --git a/src/cloudSubscriptions.psm1 b/src/cloudSubscriptions.psm1
index 7eab40df4..e7d956daa 100644
--- a/src/cloudSubscriptions.psm1
+++ b/src/cloudSubscriptions.psm1
@@ -18,7 +18,7 @@ function Get-VSTeamCloudSubscription {
# Call the REST API
$resp = _callAPI -Area 'distributedtask' -Resource 'serviceendpointproxy/azurermsubscriptions' `
- -Version $VSTeamVersionTable.DistributedTask
+ -Version $([VSTeamVersions]::DistributedTask)
# Apply a Type Name so we can use custom format view and custom type extensions
foreach ($item in $resp.value) {
diff --git a/src/common.ps1 b/src/common.ps1
index 4610cb4fe..7c4060a8e 100644
--- a/src/common.ps1
+++ b/src/common.ps1
@@ -6,7 +6,7 @@ function _testAdministrator {
}
function _hasAccount {
- if (-not $VSTeamVersionTable.Account) {
+ if (-not [VSTeamVersions]::Account) {
throw 'You must call Add-VSTeamAccount before calling any other functions in this module.'
}
}
@@ -144,11 +144,11 @@ function _addSubDomain {
$subDomain
)
- $instance = $VSTeamVersionTable.Account
+ $instance = [VSTeamVersions]::Account
# For VSTS Entitlements is under .vsaex
- if ($subDomain -and $VSTeamVersionTable.Account.ToLower().Contains('visualstudio.com')) {
- $instance = $VSTeamVersionTable.Account.ToLower().Replace('visualstudio.com', "$subDomain.visualstudio.com")
+ if ($subDomain -and [VSTeamVersions]::Account.ToLower().Contains('visualstudio.com')) {
+ $instance = [VSTeamVersions]::Account.ToLower().Replace('visualstudio.com', "$subDomain.visualstudio.com")
}
return $instance
@@ -182,7 +182,7 @@ function _getUserAgent {
$os = Get-OperatingSystem
- $result = "Team Module/$($VSTeamVersionTable.ModuleVersion) ($os) PowerShell/$($PSVersionTable.PSVersion.ToString())"
+ $result = "Team Module/$([VSTeamVersions]::ModuleVersion) ($os) PowerShell/$($PSVersionTable.PSVersion.ToString())"
Write-Verbose $result
@@ -190,7 +190,7 @@ function _getUserAgent {
}
function _useWindowsAuthenticationOnPremise {
- return (_isOnWindows) -and (!$env:TEAM_PAT) -and -not ($VSTeamVersionTable.Account -like "*visualstudio.com")
+ return (_isOnWindows) -and (!$env:TEAM_PAT) -and -not ([VSTeamVersions]::Account -like "*visualstudio.com")
}
function _useBearerToken {
@@ -203,15 +203,15 @@ function _getWorkItemTypes {
[string] $ProjectName
)
- if (-not $VSTeamVersionTable.Account) {
+ if (-not [VSTeamVersions]::Account) {
Write-Output @()
return
}
$area = "/wit"
$resource = "/workitemtypes"
- $instance = $VSTeamVersionTable.Account
- $version = $VSTeamVersionTable.Core
+ $instance = [VSTeamVersions]::Account
+ $version = [VSTeamVersions]::Core
# Build the url to list the projects
# You CANNOT use _buildRequestURI here or you will end up
@@ -237,14 +237,14 @@ function _getWorkItemTypes {
}
function _getProjects {
- if (-not $VSTeamVersionTable.Account) {
+ if (-not [VSTeamVersions]::Account) {
Write-Output @()
return
}
$resource = "/projects"
- $instance = $VSTeamVersionTable.Account
- $version = $VSTeamVersionTable.Core
+ $instance = [VSTeamVersions]::Account
+ $version = [VSTeamVersions]::Core
# Build the url to list the projects
# You CANNOT use _buildRequestURI here or you will end up
@@ -300,13 +300,13 @@ function _buildProjectNameDynamicParam {
}
# Generate and set the ValidateSet
- if($VSTeamProjectCache.timestamp -ne (Get-Date).Minute) {
+ if($([VSTeamProjectCache]::timestamp) -ne (Get-Date).Minute) {
$arrSet = _getProjects
- $VSTeamProjectCache.projects = $arrSet
- $VSTeamProjectCache.timestamp = (Get-Date).Minute
+ [VSTeamProjectCache]::projects = $arrSet
+ [VSTeamProjectCache]::timestamp = (Get-Date).Minute
}
else {
- $arrSet = $VSTeamProjectCache.projects
+ $arrSet = [VSTeamProjectCache]::projects
}
if ($arrSet) {
diff --git a/src/policies.psm1 b/src/policies.psm1
index 5f53dc904..a36f07614 100644
--- a/src/policies.psm1
+++ b/src/policies.psm1
@@ -29,7 +29,7 @@ function Get-VSTeamPolicy {
if ($id) {
foreach ($item in $id) {
try {
- $resp = _callAPI -ProjectName $ProjectName -Id $item -Area policy -Resource configurations -Version $VSTeamVersionTable.Git
+ $resp = _callAPI -ProjectName $ProjectName -Id $item -Area policy -Resource configurations -Version $([VSTeamVersions]::Git)
_applyTypesToPolicy -item $resp
@@ -42,7 +42,7 @@ function Get-VSTeamPolicy {
}
else {
try {
- $resp = _callAPI -ProjectName $ProjectName -Area policy -Resource configurations -Version $VSTeamVersionTable.Git
+ $resp = _callAPI -ProjectName $ProjectName -Area policy -Resource configurations -Version $([VSTeamVersions]::Git)
# Apply a Type Name so we can use custom format view and custom type extensions
foreach ($item in $resp.value) {
@@ -91,7 +91,7 @@ function Add-VSTeamPolicy {
try {
# Call the REST API
$resp = _callAPI -ProjectName $ProjectName -Area 'policy' -Resource 'configurations' `
- -Method Post -ContentType 'application/json' -Body $body -Version $VSTeamVersionTable.Git
+ -Method Post -ContentType 'application/json' -Body $body -Version $([VSTeamVersions]::Git)
Write-Output $resp
}
@@ -145,7 +145,7 @@ function Update-VSTeamPolicy {
if ($Force -or $pscmdlet.ShouldProcess($id, "Update Policy")) {
# Call the REST API
$resp = _callAPI -ProjectName $ProjectName -Area 'policy' -id $id -Resource 'configurations' `
- -Method Put -ContentType 'application/json' -Body $body -Version $VSTeamVersionTable.Git
+ -Method Put -ContentType 'application/json' -Body $body -Version $([VSTeamVersions]::Git)
Write-Output $resp
}
@@ -175,7 +175,7 @@ function Remove-VSTeamPolicy {
foreach ($item in $id) {
if ($Force -or $pscmdlet.ShouldProcess($item, "Delete Policy")) {
try {
- _callAPI -ProjectName $ProjectName -Method Delete -Id $item -Area policy -Resource configurations -Version $VSTeamVersionTable.Git | Out-Null
+ _callAPI -ProjectName $ProjectName -Method Delete -Id $item -Area policy -Resource configurations -Version $([VSTeamVersions]::Git) | Out-Null
Write-Output "Deleted policy $item"
}
diff --git a/src/policyTypes.psm1 b/src/policyTypes.psm1
index 055341eea..b91d70f95 100644
--- a/src/policyTypes.psm1
+++ b/src/policyTypes.psm1
@@ -30,7 +30,7 @@ function Get-VSTeamPolicyType {
if ($id) {
foreach ($item in $id) {
try {
- $resp = _callAPI -ProjectName $ProjectName -Id $item -Area policy -Resource types -Version $VSTeamVersionTable.Git
+ $resp = _callAPI -ProjectName $ProjectName -Id $item -Area policy -Resource types -Version $([VSTeamVersions]::Git)
_applyTypesToPolicyType -item $resp
@@ -43,7 +43,7 @@ function Get-VSTeamPolicyType {
}
else {
try {
- $resp = _callAPI -ProjectName $ProjectName -Area policy -Resource types -Version $VSTeamVersionTable.Git
+ $resp = _callAPI -ProjectName $ProjectName -Area policy -Resource types -Version $([VSTeamVersions]::Git)
# Apply a Type Name so we can use custom format view and custom type extensions
foreach ($item in $resp.value) {
diff --git a/src/pools.psm1 b/src/pools.psm1
index 43027fd9b..1f7b5f3f0 100644
--- a/src/pools.psm1
+++ b/src/pools.psm1
@@ -15,7 +15,7 @@ function Get-VSTeamPool {
process {
if ($id) {
- $resp = _callAPI -Area distributedtask -Resource pools -Id $id -Version $VSTeamVersionTable.DistributedTask
+ $resp = _callAPI -Area distributedtask -Resource pools -Id $id -Version $([VSTeamVersions]::DistributedTask)
# Storing the object before you return it cleaned up the pipeline.
# When I just write the object from the constructor each property
@@ -25,7 +25,7 @@ function Get-VSTeamPool {
Write-Output $item
}
else {
- $resp = _callAPI -Area distributedtask -Resource pools -Version $VSTeamVersionTable.DistributedTask
+ $resp = _callAPI -Area distributedtask -Resource pools -Version $([VSTeamVersions]::DistributedTask)
$objs = @()
diff --git a/src/projects.psm1 b/src/projects.psm1
index 9e96ca697..81a326ba7 100644
--- a/src/projects.psm1
+++ b/src/projects.psm1
@@ -70,7 +70,7 @@ function Get-VSTeamProject {
# Call the REST API
$resp = _callAPI -Area 'projects' -id $ProjectName `
- -Version $VSTeamVersionTable.Core `
+ -Version $([VSTeamVersions]::Core) `
-QueryString $queryString
# Storing the object before you return it cleaned up the pipeline.
@@ -84,7 +84,7 @@ function Get-VSTeamProject {
try {
# Call the REST API
$resp = _callAPI -Area 'projects' `
- -Version $VSTeamVersionTable.Core `
+ -Version $([VSTeamVersions]::Core) `
-QueryString @{
stateFilter = $stateFilter
'$top' = $top
@@ -131,7 +131,7 @@ function Show-VSTeamProject {
$ProjectName = $id
}
- Show-Browser "$($VSTeamVersionTable.Account)/$ProjectName"
+ Show-Browser "$([VSTeamVersions]::Account)/$ProjectName"
}
}
@@ -189,12 +189,12 @@ function Update-VSTeamProject {
# Call the REST API
$resp = _callAPI -Area 'projects' -id $id `
- -Method Patch -ContentType 'application/json' -body $body -Version $VSTeamVersionTable.Core
+ -Method Patch -ContentType 'application/json' -body $body -Version $([VSTeamVersions]::Core)
_trackProjectProgress -resp $resp -title 'Updating team project' -msg $msg
# Invalidate any cache of projects.
- $VSTeamProjectCache.timestamp = -1
+ [VSTeamProjectCache]::timestamp = -1
# Return the project now that it has been updated
return Get-VSTeamProject -Id $finalName
@@ -241,12 +241,12 @@ function Add-VSTeamProject {
try {
# Call the REST API
$resp = _callAPI -Area 'projects' `
- -Method Post -ContentType 'application/json' -body $body -Version $VSTeamVersionTable.Core
+ -Method Post -ContentType 'application/json' -body $body -Version $([VSTeamVersions]::Core)
_trackProjectProgress -resp $resp -title 'Creating team project' -msg "Name: $($ProjectName), Template: $($processTemplate), Src: $($srcCtrl)"
# Invalidate any cache of projects.
- $VSTeamProjectCache.timestamp = -1
+ [VSTeamProjectCache]::timestamp = -1
return Get-VSTeamProject $ProjectName
}
@@ -272,12 +272,12 @@ function Remove-VSTeamProject {
if ($Force -or $pscmdlet.ShouldProcess($ProjectName, "Delete Project")) {
# Call the REST API
$resp = _callAPI -Area 'projects' -Id (Get-VSTeamProject $ProjectName).id `
- -Method Delete -Version $VSTeamVersionTable.Core
+ -Method Delete -Version $([VSTeamVersions]::Core)
_trackProjectProgress -resp $resp -title 'Deleting team project' -msg "Deleting $ProjectName"
# Invalidate any cache of projects.
- $VSTeamProjectCache.timestamp = -1
+ [VSTeamProjectCache]::timestamp = -1
Write-Output "Deleted $ProjectName"
}
@@ -352,7 +352,7 @@ function Clear-VSTeamDefaultProject {
[System.Environment]::SetEnvironmentVariable("TEAM_PROJECT", $null, $Level)
}
- $VSTeamVersionTable.DefaultProject = ''
+ [VSTeamVersions]::DefaultProject = ''
$Global:PSDefaultParameterValues.Remove("*:projectName")
Write-Output "Removed default project"
@@ -421,7 +421,7 @@ function Set-VSTeamDefaultProject {
# You always have to set at the process level or they will Not
# be seen in your current session.
$env:TEAM_PROJECT = $Project
- $VSTeamVersionTable.DefaultProject = $Project
+ [VSTeamVersions]::DefaultProject = $Project
[System.Environment]::SetEnvironmentVariable("TEAM_PROJECT", $Project, $Level)
}
diff --git a/src/queues.psm1 b/src/queues.psm1
index 0be18cb8e..eb3a9682e 100644
--- a/src/queues.psm1
+++ b/src/queues.psm1
@@ -36,7 +36,7 @@ function Get-VSTeamQueue {
if ($id) {
$resp = _callAPI -ProjectName $ProjectName -Id $id -Area distributedtask -Resource queues `
- -Version $VSTeamVersionTable.DistributedTask
+ -Version $([VSTeamVersions]::DistributedTask)
_applyTypesToQueue -item $resp
@@ -44,7 +44,7 @@ function Get-VSTeamQueue {
}
else {
$resp = _callAPI -ProjectName $projectName -Area distributedtask -Resource queues `
- -QueryString @{ queueName = $queueName; actionFilter = $actionFilter } -Version $VSTeamVersionTable.DistributedTask
+ -QueryString @{ queueName = $queueName; actionFilter = $actionFilter } -Version $([VSTeamVersions]::DistributedTask)
# Apply a Type Name so we can use custom format view and custom type extensions
foreach ($item in $resp.value) {
diff --git a/src/refs.psm1 b/src/refs.psm1
index cc5f86a06..2d96a8bd8 100644
--- a/src/refs.psm1
+++ b/src/refs.psm1
@@ -21,7 +21,7 @@ function Get-VSTeamGitRef {
$ProjectName = $PSBoundParameters["ProjectName"]
try {
- $resp = _callAPI -ProjectName $ProjectName -Id "$RepositoryID/refs" -Area git -Resource repositories -Version $VSTeamVersionTable.Git
+ $resp = _callAPI -ProjectName $ProjectName -Id "$RepositoryID/refs" -Area git -Resource repositories -Version $([VSTeamVersions]::Git)
$obj = @()
diff --git a/src/releaseDefinitions.psm1 b/src/releaseDefinitions.psm1
index 2926266fd..3f91a2c88 100644
--- a/src/releaseDefinitions.psm1
+++ b/src/releaseDefinitions.psm1
@@ -55,7 +55,7 @@ function Get-VSTeamReleaseDefinition {
if ($id) {
foreach ($item in $id) {
- $resp = _callAPI -subDomain vsrm -Area release -resource definitions -version $VSTeamVersionTable.Release -projectName $projectName -id $item
+ $resp = _callAPI -subDomain vsrm -Area release -resource definitions -Version $([VSTeamVersions]::Release) -projectName $projectName -id $item
# Apply a Type Name so we can use custom format view and custom type extensions
_applyTypesToReleaseDefinition -item $resp
@@ -64,7 +64,7 @@ function Get-VSTeamReleaseDefinition {
}
}
else {
- $listurl = _buildRequestURI -subDomain vsrm -Area release -resource 'definitions' -version $VSTeamVersionTable.Release -projectName $ProjectName
+ $listurl = _buildRequestURI -subDomain vsrm -Area release -resource 'definitions' -Version $([VSTeamVersions]::Release) -projectName $ProjectName
if ($expand -ne 'none') {
$listurl += "&`$expand=$($expand)"
@@ -102,7 +102,7 @@ function Show-VSTeamReleaseDefinition {
$ProjectName = $PSBoundParameters["ProjectName"]
# Build the url
- $url = "$($VSTeamVersionTable.Account)/$ProjectName/_release"
+ $url = "$([VSTeamVersions]::Account)/$ProjectName/_release"
if ($id) {
$url += "?definitionId=$id"
@@ -130,7 +130,7 @@ function Add-VSTeamReleaseDefinition {
$ProjectName = $PSBoundParameters["ProjectName"]
$resp = _callAPI -Method Post -subDomain vsrm -Area release -Resource definitions -ProjectName $ProjectName `
- -version $VSTeamVersionTable.Release -inFile $inFile -ContentType 'application/json'
+ -Version $([VSTeamVersions]::Release) -inFile $inFile -ContentType 'application/json'
Write-Output $resp
}
@@ -158,7 +158,7 @@ function Remove-VSTeamReleaseDefinition {
foreach ($item in $id) {
if ($force -or $pscmdlet.ShouldProcess($item, "Delete Release Definition")) {
- _callAPI -Method Delete -subDomain vsrm -Area release -Resource definitions -Version $VSTeamVersionTable.Release -projectName $ProjectName -id $item | Out-Null
+ _callAPI -Method Delete -subDomain vsrm -Area release -Resource definitions -Version $([VSTeamVersions]::Release) -projectName $ProjectName -id $item | Out-Null
Write-Output "Deleted release defintion $item"
}
diff --git a/src/releases.psm1 b/src/releases.psm1
index 993dc5a0f..1b4ee491e 100644
--- a/src/releases.psm1
+++ b/src/releases.psm1
@@ -71,7 +71,7 @@ function Get-VSTeamRelease {
if ($id) {
foreach ($item in $id) {
- $resp = _callAPI -SubDomain vsrm -ProjectName $ProjectName -Area release -id $item -Resource releases -Version $VSTeamVersionTable.Release
+ $resp = _callAPI -SubDomain vsrm -ProjectName $ProjectName -Area release -id $item -Resource releases -Version $([VSTeamVersions]::Release)
# Apply a Type Name so we can use custom format view and custom type extensions
_applyTypesToRelease -item $resp
@@ -81,10 +81,10 @@ function Get-VSTeamRelease {
}
else {
if ($ProjectName) {
- $listurl = _buildRequestURI -SubDomain vsrm -ProjectName $ProjectName -Area release -Resource releases -Version $VSTeamVersionTable.Release
+ $listurl = _buildRequestURI -SubDomain vsrm -ProjectName $ProjectName -Area release -Resource releases -Version $([VSTeamVersions]::Release)
}
else {
- $listurl = _buildRequestURI -SubDomain vsrm -Area release -Resource releases -Version $VSTeamVersionTable.Release
+ $listurl = _buildRequestURI -SubDomain vsrm -Area release -Resource releases -Version $([VSTeamVersions]::Release)
}
$QueryString = @{
@@ -135,7 +135,7 @@ function Show-VSTeamRelease {
$ProjectName = $PSBoundParameters["ProjectName"]
# Build the url
- Show-Browser "$($VSTeamVersionTable.Account)/$ProjectName/_release?releaseId=$id"
+ Show-Browser "$([VSTeamVersions]::Account)/$ProjectName/_release?releaseId=$id"
}
}
@@ -232,7 +232,7 @@ function Add-VSTeamRelease {
try {
Write-Debug 'Add-VSTeamRelease Call the REST API'
$resp = _callAPI -SubDomain 'vsrm' -ProjectName $ProjectName -Area 'release' -Resource 'releases' `
- -Method Post -ContentType 'application/json' -Body $body -Version $VSTeamVersionTable.Release
+ -Method Post -ContentType 'application/json' -Body $body -Version $([VSTeamVersions]::Release)
_applyTypesToRelease $resp
@@ -271,7 +271,7 @@ function Remove-VSTeamRelease {
try {
# Call the REST API
- _callAPI -Method Delete -SubDomain vsrm -Area release -Resource releases -ProjectName $ProjectName -id $item -Version $VSTeamVersionTable.Release | Out-Null
+ _callAPI -Method Delete -SubDomain vsrm -Area release -Resource releases -ProjectName $ProjectName -id $item -Version $([VSTeamVersions]::Release) | Out-Null
Write-Output "Deleted release $item"
}
@@ -315,7 +315,7 @@ function Set-VSTeamReleaseStatus {
try {
# Call the REST API
_callAPI -Method Patch -SubDomain vsrm -Area release -Resource releases -projectName $ProjectName -id $item `
- -body $body -ContentType 'application/json' -Version $VSTeamVersionTable.Release | Out-Null
+ -body $body -ContentType 'application/json' -Version $([VSTeamVersions]::Release) | Out-Null
Write-Output "Release $item status changed to $status"
}
@@ -369,7 +369,7 @@ function Set-VSTeamEnvironmentStatus {
try {
# Call the REST API
_callAPI -Method Patch -SubDomain vsrm -Area release -Resource "releases/$ReleaseId/environments" -projectName $ProjectName -id $item `
- -body $body -ContentType 'application/json' -Version $VSTeamVersionTable.Release | Out-Null
+ -body $body -ContentType 'application/json' -Version $([VSTeamVersions]::Release) | Out-Null
Write-Output "Environment $item status changed to $status"
}
diff --git a/src/repositories.psm1 b/src/repositories.psm1
index 4dc85eda5..1d4f9b607 100644
--- a/src/repositories.psm1
+++ b/src/repositories.psm1
@@ -16,7 +16,7 @@ function Remove-VSTeamGitRepository {
foreach ($item in $id) {
if ($Force -or $pscmdlet.ShouldProcess($item, "Delete Repository")) {
try {
- _callAPI -Method Delete -Id $item -Area git -Resource repositories -Version $VSTeamVersionTable.Git | Out-Null
+ _callAPI -Method Delete -Id $item -Area git -Resource repositories -Version $([VSTeamVersions]::Git) | Out-Null
Write-Output "Deleted repository $item"
}
@@ -47,7 +47,7 @@ function Add-VSTeamGitRepository {
try {
# Call the REST API
$resp = _callAPI -ProjectName $ProjectName -Area 'git' -Resource 'repositories' `
- -Method Post -ContentType 'application/json' -Body $body -Version $VSTeamVersionTable.Git
+ -Method Post -ContentType 'application/json' -Body $body -Version $([VSTeamVersions]::Git)
# Storing the object before you return it cleaned up the pipeline.
# When I just write the object from the constructor each property
@@ -84,7 +84,7 @@ function Get-VSTeamGitRepository {
if ($id) {
foreach ($item in $id) {
try {
- $resp = _callAPI -ProjectName $ProjectName -Id $item -Area git -Resource repositories -Version $VSTeamVersionTable.Git
+ $resp = _callAPI -ProjectName $ProjectName -Id $item -Area git -Resource repositories -Version $([VSTeamVersions]::Git)
# Storing the object before you return it cleaned up the pipeline.
# When I just write the object from the constructor each property
@@ -101,7 +101,7 @@ function Get-VSTeamGitRepository {
elseif ($Name) {
foreach ($item in $Name) {
try {
- $resp = _callAPI -ProjectName $ProjectName -Id $item -Area git -Resource repositories -Version $VSTeamVersionTable.Git
+ $resp = _callAPI -ProjectName $ProjectName -Id $item -Area git -Resource repositories -Version $([VSTeamVersions]::Git)
# Storing the object before you return it cleaned up the pipeline.
# When I just write the object from the constructor each property
@@ -117,7 +117,7 @@ function Get-VSTeamGitRepository {
}
else {
try {
- $resp = _callAPI -ProjectName $ProjectName -Area git -Resource repositories -Version $VSTeamVersionTable.Git
+ $resp = _callAPI -ProjectName $ProjectName -Area git -Resource repositories -Version $([VSTeamVersions]::Git)
$objs = @()
@@ -153,7 +153,7 @@ function Show-VSTeamGitRepository {
Show-Browser $RemoteUrl
}
else {
- Show-Browser "$($VSTeamVersionTable.Account)/_git/$ProjectName"
+ Show-Browser "$([VSTeamVersions]::Account)/_git/$ProjectName"
}
}
}
diff --git a/src/serviceendpointTypes.psm1 b/src/serviceendpointTypes.psm1
index d577c7101..3cbd47b75 100644
--- a/src/serviceendpointTypes.psm1
+++ b/src/serviceendpointTypes.psm1
@@ -65,12 +65,12 @@ function Get-VSTeamServiceEndpointType {
# Call the REST API
$resp = _callAPI -Area 'distributedtask' -Resource 'serviceendpointtypes' `
- -Version $VSTeamVersionTable.DistributedTask -body $body
+ -Version $([VSTeamVersions]::DistributedTask) -body $body
}
else {
# Call the REST API
$resp = _callAPI -Area 'distributedtask' -Resource 'serviceendpointtypes' `
- -Version $VSTeamVersionTable.DistributedTask
+ -Version $([VSTeamVersions]::DistributedTask)
}
diff --git a/src/serviceendpoints.psm1 b/src/serviceendpoints.psm1
index 050760f40..4a9cc28bf 100644
--- a/src/serviceendpoints.psm1
+++ b/src/serviceendpoints.psm1
@@ -48,7 +48,7 @@ function _trackProgress {
# Track status
while (-not $isReady) {
$status = _callAPI -ProjectName $projectName -Area 'distributedtask' -Resource 'serviceendpoints' -Id $resp.id `
- -Version $VSTeamVersionTable.DistributedTask
+ -Version $([VSTeamVersions]::DistributedTask)
$isReady = $status.isReady;
@@ -71,7 +71,7 @@ function _trackProgress {
}
function _supportsServiceFabricEndpoint {
- if (-not $VSTeamVersionTable.ServiceFabricEndpoint) {
+ if (-not [VSTeamVersions]::ServiceFabricEndpoint) {
throw 'This account does not support Service Fabric endpoints.'
}
}
@@ -403,7 +403,7 @@ function Add-VSTeamServiceEndpoint {
# Call the REST API
$resp = _callAPI -ProjectName $projectName -Area 'distributedtask' -Resource 'serviceendpoints' `
- -Method Post -ContentType 'application/json' -body $body -Version $VSTeamVersionTable.DistributedTask
+ -Method Post -ContentType 'application/json' -body $body -Version $([VSTeamVersions]::DistributedTask)
_trackProgress -projectName $projectName -resp $resp -title 'Creating Service Endpoint' -msg "Creating $endpointName"
@@ -429,7 +429,7 @@ function Get-VSTeamServiceEndpoint {
if ($id) {
# Call the REST API
$resp = _callAPI -Area 'distributedtask' -Resource 'serviceendpoints' -Id $id `
- -Version $VSTeamVersionTable.DistributedTask -ProjectName $ProjectName
+ -Version $([VSTeamVersions]::DistributedTask) -ProjectName $ProjectName
_applyTypesToServiceEndpoint -item $resp
@@ -438,7 +438,7 @@ function Get-VSTeamServiceEndpoint {
else {
# Call the REST API
$resp = _callAPI -ProjectName $ProjectName -Area 'distributedtask' -Resource 'serviceendpoints' `
- -Version $VSTeamVersionTable.DistributedTask
+ -Version $([VSTeamVersions]::DistributedTask)
# Apply a Type Name so we can use custom format view and custom type extensions
foreach ($item in $resp.value) {
@@ -451,13 +451,15 @@ function Get-VSTeamServiceEndpoint {
}
function Update-VSTeamServiceEndpoint {
- [CmdletBinding()]
+ [CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = "Medium")]
param(
[Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true)]
[string] $id,
[Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true)]
- [hashtable] $object
+ [hashtable] $object,
+
+ [switch] $Force
)
DynamicParam {
@@ -470,13 +472,15 @@ function Update-VSTeamServiceEndpoint {
$body = $object | ConvertTo-Json
- # Call the REST API
- $resp = _callAPI -ProjectName $projectName -Area 'distributedtask' -Resource 'serviceendpoints' -Id $id `
- -Method Put -ContentType 'application/json' -body $body -Version $VSTeamVersionTable.DistributedTask
+ if ($Force -or $pscmdlet.ShouldProcess($id, "Update Service Endpoint")) {
+ # Call the REST API
+ $resp = _callAPI -ProjectName $projectName -Area 'distributedtask' -Resource 'serviceendpoints' -Id $id `
+ -Method Put -ContentType 'application/json' -body $body -Version $([VSTeamVersions]::DistributedTask)
- _trackProgress -projectName $projectName -resp $resp -title 'Updating Service Endpoint' -msg "Updating $id"
+ _trackProgress -projectName $projectName -resp $resp -title 'Updating Service Endpoint' -msg "Updating $id"
- return Get-VSTeamServiceEndpoint -ProjectName $ProjectName -id $id
+ return Get-VSTeamServiceEndpoint -ProjectName $ProjectName -id $id
+ }
}
}
@@ -501,7 +505,7 @@ function Remove-VSTeamServiceEndpoint {
if ($Force -or $pscmdlet.ShouldProcess($item, "Delete Service Endpoint")) {
# Call the REST API
_callAPI -projectName $projectName -Area 'distributedtask' -Resource 'serviceendpoints' -Id $item `
- -Method Delete -Version $VSTeamVersionTable.DistributedTask | Out-Null
+ -Method Delete -Version $([VSTeamVersions]::DistributedTask) | Out-Null
Write-Output "Deleted service endpoint $item"
}
diff --git a/src/team.psm1 b/src/team.psm1
index 4666411c0..ddae741a1 100644
--- a/src/team.psm1
+++ b/src/team.psm1
@@ -42,7 +42,7 @@ function _setEnvironmentVariables {
$env:TEAM_ACCT = $Acct
$env:TEAM_TOKEN = $BearerToken
- $VSTeamVersionTable.Account = $Acct
+ [VSTeamVersions]::Account = $Acct
# This is so it can be loaded by default in the next session
if ($Level -ne "Process") {
@@ -59,7 +59,7 @@ function _clearEnvironmentVariables {
)
$env:TEAM_PROJECT = $null
- $VSTeamVersionTable.DefaultProject = ''
+ [VSTeamVersions]::DefaultProject = ''
$Global:PSDefaultParameterValues.Remove("*:projectName")
# This is so it can be loaded by default in the next session
@@ -72,9 +72,9 @@ function _clearEnvironmentVariables {
function Get-VSTeamInfo {
return @{
- Account = $VSTeamVersionTable.Account
- Version = $VSTeamVersionTable.Version
- ModuleVersion = $VSTeamVersionTable.ModuleVersion
+ Account = [VSTeamVersions]::Account
+ Version = [VSTeamVersions]::Version
+ ModuleVersion = [VSTeamVersions]::ModuleVersion
DefaultProject = $Global:PSDefaultParameterValues['*:projectName']
}
}
@@ -86,7 +86,7 @@ function Show-VSTeam {
process {
_hasAccount
- Show-Browser "$($VSTeamVersionTable.Account)"
+ Show-Browser "$([VSTeamVersions]::Account)"
}
}
@@ -377,6 +377,23 @@ function Remove-VSTeamAccount {
}
}
+function Get-VSTeamAPIVersion {
+ [CmdletBinding()]
+ param()
+
+ return @{
+ Version = $([VSTeamVersions]::Version)
+ Git = $([VSTeamVersions]::Git)
+ Core = $([VSTeamVersions]::Core)
+ Build = $([VSTeamVersions]::Build)
+ Release = $([VSTeamVersions]::Release)
+ DistributedTask = $([VSTeamVersions]::DistributedTask)
+ Tfvc = $([VSTeamVersions]::Tfvc)
+ MemberEntitlementManagement = $([VSTeamVersions]::MemberEntitlementManagement)
+ ServiceFabricEndpoint = $([VSTeamVersions]::ServiceFabricEndpoint)
+ }
+}
+
function Set-VSTeamAPIVersion {
[CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = "Low")]
param(
@@ -388,50 +405,50 @@ function Set-VSTeamAPIVersion {
if ($Force -or $pscmdlet.ShouldProcess($version, "Set-VSTeamAPIVersion")) {
switch ($version) {
'TFS2018' {
- $VSTeamVersionTable.Version = 'TFS2018'
- $VSTeamVersionTable.Git = '3.2'
- $VSTeamVersionTable.Core = '3.2'
- $VSTeamVersionTable.Build = '3.2'
- $VSTeamVersionTable.Release = '4.0-preview'
- $VSTeamVersionTable.DistributedTask = '4.0-preview'
- $VSTeamVersionTable.Tfvc = '3.2'
- $VSTeamVersionTable.MemberEntitlementManagement = ''
- $VSTeamVersionTable.ServiceFabricEndpoint = '3.2'
+ [VSTeamVersions]::Version = 'TFS2018'
+ [VSTeamVersions]::Git = '3.2'
+ [VSTeamVersions]::Core = '3.2'
+ [VSTeamVersions]::Build = '3.2'
+ [VSTeamVersions]::Release = '4.0-preview'
+ [VSTeamVersions]::DistributedTask = '4.0-preview'
+ [VSTeamVersions]::Tfvc = '3.2'
+ [VSTeamVersions]::MemberEntitlementManagement = ''
+ [VSTeamVersions]::ServiceFabricEndpoint = '3.2'
}
'VSTS' {
- $VSTeamVersionTable.Version = 'VSTS'
- $VSTeamVersionTable.Git = '4.0'
- $VSTeamVersionTable.Core = '4.0'
- $VSTeamVersionTable.Build = '4.0'
- $VSTeamVersionTable.Release = '4.1-preview'
- $VSTeamVersionTable.DistributedTask = '4.1-preview'
- $VSTeamVersionTable.Tfvc = '4.0'
- $VSTeamVersionTable.MemberEntitlementManagement = '4.1-preview'
- $VSTeamVersionTable.ServiceFabricEndpoint = '4.1-preview'
+ [VSTeamVersions]::Version = 'VSTS'
+ [VSTeamVersions]::Git = '4.0'
+ [VSTeamVersions]::Core = '4.0'
+ [VSTeamVersions]::Build = '4.0'
+ [VSTeamVersions]::Release = '4.1-preview'
+ [VSTeamVersions]::DistributedTask = '4.1-preview'
+ [VSTeamVersions]::Tfvc = '4.0'
+ [VSTeamVersions]::MemberEntitlementManagement = '4.1-preview'
+ [VSTeamVersions]::ServiceFabricEndpoint = '4.1-preview'
}
Default {
- $VSTeamVersionTable.Version = 'TFS2017'
- $VSTeamVersionTable.Git = '3.0'
- $VSTeamVersionTable.Core = '3.0'
- $VSTeamVersionTable.Build = '3.0'
- $VSTeamVersionTable.Release = '3.0-preview'
- $VSTeamVersionTable.DistributedTask = '3.0-preview'
- $VSTeamVersionTable.Tfvc = '3.0'
- $VSTeamVersionTable.MemberEntitlementManagement = ''
- $VSTeamVersionTable.ServiceFabricEndpoint = ''
+ [VSTeamVersions]::Version = 'TFS2017'
+ [VSTeamVersions]::Git = '3.0'
+ [VSTeamVersions]::Core = '3.0'
+ [VSTeamVersions]::Build = '3.0'
+ [VSTeamVersions]::Release = '3.0-preview'
+ [VSTeamVersions]::DistributedTask = '3.0-preview'
+ [VSTeamVersions]::Tfvc = '3.0'
+ [VSTeamVersions]::MemberEntitlementManagement = ''
+ [VSTeamVersions]::ServiceFabricEndpoint = ''
}
}
}
- Write-Verbose $VSTeamVersionTable.Version
- Write-Verbose "Git: $($VSTeamVersionTable.Git)"
- Write-Verbose "Core: $($VSTeamVersionTable.Core)"
- Write-Verbose "Build: $($VSTeamVersionTable.Build)"
- Write-Verbose "Release: $($VSTeamVersionTable.Release)"
- Write-Verbose "DistributedTask: $($VSTeamVersionTable.DistributedTask)"
- Write-Verbose "Tfvc: $($VSTeamVersionTable.Tfvc)"
- Write-Verbose "MemberEntitlementManagement: $($VSTeamVersionTable.MemberEntitlementManagement)"
- Write-Verbose "ServiceFabricEndpoint: $($VSTeamVersionTable.ServiceFabricEndpoint)"
+ Write-Verbose [VSTeamVersions]::Version
+ Write-Verbose "Git: $([VSTeamVersions]::Git)"
+ Write-Verbose "Core: $([VSTeamVersions]::Core)"
+ Write-Verbose "Build: $([VSTeamVersions]::Build)"
+ Write-Verbose "Release: $([VSTeamVersions]::Release)"
+ Write-Verbose "DistributedTask: $([VSTeamVersions]::DistributedTask)"
+ Write-Verbose "Tfvc: $([VSTeamVersions]::Tfvc)"
+ Write-Verbose "MemberEntitlementManagement: $([VSTeamVersions]::MemberEntitlementManagement)"
+ Write-Verbose "ServiceFabricEndpoint: $([VSTeamVersions]::ServiceFabricEndpoint)"
}
function Invoke-VSTeamRequest {
@@ -473,28 +490,8 @@ function Invoke-VSTeamRequest {
}
}
-$Global:VSTeamVersionTable = @{
- 'Account' = $env:TEAM_ACCT
- 'DefaultProject' = $env:TEAM_PROJECT
- 'Version' = 'TFS2017'
- 'Build' = '3.0'
- 'Release' = '3.0-preview'
- 'Core' = '3.0'
- 'Git' = '3.0'
- 'DistributedTask' = '3.0-preview'
- 'Tfvc' = '3.0'
- 'MemberEntitlementManagement' = ''
- 'ServiceFabricEndpoint' = ''
- 'ModuleVersion' = _getModuleVersion
-}
-
-# Dynamic parameters get called alot. This can cause
-# multiple calls to TFS/VSTS for a single function call
-# so I am going to try and cache the values.
-$Global:VSTeamProjectCache = @{
- 'projects' = $null
- 'timestamp' = -1
-}
+# Set the module version
+[VSTeamVersions]::ModuleVersion = _getModuleVersion
Set-Alias gti Get-VSTeamInfo
Set-Alias ata Add-VSTeamAccount
@@ -505,7 +502,8 @@ Set-Alias Remove-TeamAccount Remove-VSTeamAccount
Set-Alias Get-TeamOption Get-VSTeamOption
Set-Alias Get-TeamResourceArea Get-VSTeamResourceArea
Set-Alias Set-APIVersion Set-VSTeamAPIVersion
+Set-Alias Get-APIVersion Get-VSTeamAPIVersion
Export-ModuleMember `
- -Function Get-VSTeamInfo, Add-VSTeamAccount, Remove-VSTeamAccount, Get-VSTeamOption, Show-VSTeam, Get-VSTeamResourceArea, Set-VSTeamAPIVersion, Invoke-VSTeamRequest `
- -Alias Get-TeamInfo, Add-TeamAccount, Remove-TeamAccount, Get-TeamOption, Get-TeamResourceArea, Set-APIVersion, gti, ivr, ata
\ No newline at end of file
+ -Function Get-VSTeamInfo, Add-VSTeamAccount, Remove-VSTeamAccount, Get-VSTeamOption, Show-VSTeam, Get-VSTeamResourceArea, Set-VSTeamAPIVersion, Invoke-VSTeamRequest, Get-VSTeamAPIVersion `
+ -Alias Get-TeamInfo, Add-TeamAccount, Remove-TeamAccount, Get-TeamOption, Get-TeamResourceArea, Set-APIVersion, gti, ivr, ata, Get-APIVersion
\ No newline at end of file
diff --git a/src/teammembers.psm1 b/src/teammembers.psm1
index 197992f07..e10b26720 100644
--- a/src/teammembers.psm1
+++ b/src/teammembers.psm1
@@ -45,7 +45,7 @@ function Get-VSTeamMember {
# Bind the parameter to a friendly variable
$ProjectName = $PSBoundParameters["ProjectName"]
- $resp = _callAPI -Id "$TeamId/members" -Area 'projects' -Resource "$ProjectName/teams" -Version $VSTeamVersionTable.Core `
+ $resp = _callAPI -Id "$TeamId/members" -Area 'projects' -Resource "$ProjectName/teams" -Version $([VSTeamVersions]::Core) `
-QueryString @{'$top' = $top; '$skip' = $skip}
# Apply a Type Name so we can use custom format view and custom type extensions
diff --git a/src/teams.psm1 b/src/teams.psm1
index a11bf3e52..7572d2c89 100644
--- a/src/teams.psm1
+++ b/src/teams.psm1
@@ -34,7 +34,7 @@ function Get-VSTeam {
foreach ($item in $Id) {
# Call the REST API
$resp = _callAPI -Area 'projects' -Resource "$ProjectName/teams" -id $item `
- -Version $VSTeamVersionTable.Core
+ -Version $([VSTeamVersions]::Core)
$team = [VSTeamTeam]::new($resp, $ProjectName)
@@ -45,7 +45,7 @@ function Get-VSTeam {
foreach ($item in $Name) {
# Call the REST API
$resp = _callAPI -Area 'projects' -Resource "$ProjectName/teams" -id $item `
- -Version $VSTeamVersionTable.Core
+ -Version $([VSTeamVersions]::Core)
$team = [VSTeamTeam]::new($resp, $ProjectName)
@@ -55,7 +55,7 @@ function Get-VSTeam {
else {
# Call the REST API
$resp = _callAPI -Area 'projects' -Resource "$ProjectName/teams" `
- -Version $VSTeamVersionTable.Core `
+ -Version $([VSTeamVersions]::Core) `
-QueryString @{
'$top' = $top
'$skip' = $skip
@@ -94,7 +94,7 @@ function Add-VSTeam {
# Call the REST API
$resp = _callAPI -Area 'projects' -Resource "$ProjectName/teams" `
- -Method Post -ContentType 'application/json' -Body $body -Version $VSTeamVersionTable.Core
+ -Method Post -ContentType 'application/json' -Body $body -Version $([VSTeamVersions]::Core)
$team = [VSTeamTeam]::new($resp, $ProjectName)
@@ -137,7 +137,7 @@ function Update-VSTeam {
# Call the REST API
$resp = _callAPI -Area 'projects' -Resource "$ProjectName/teams" -Id $Name `
- -Method Patch -ContentType 'application/json' -Body $body -Version $VSTeamVersionTable.Core
+ -Method Patch -ContentType 'application/json' -Body $body -Version $([VSTeamVersions]::Core)
# Storing the object before you return it cleaned up the pipeline.
# When I just write the object from the constructor each property
@@ -169,7 +169,7 @@ function Remove-VSTeam {
if ($Force -or $PSCmdlet.ShouldProcess($Id, "Delete team")) {
# Call the REST API
_callAPI -Area 'projects' -Resource "$ProjectName/teams" -Id $Id `
- -Method Delete -Version $VSTeamVersionTable.Core | Out-Null
+ -Method Delete -Version $([VSTeamVersions]::Core) | Out-Null
Write-Output "Deleted team $Id"
}
diff --git a/src/teamspsdrive.ps1 b/src/teamspsdrive.ps1
index ff3d5c49b..9e957d2b3 100644
--- a/src/teamspsdrive.ps1
+++ b/src/teamspsdrive.ps1
@@ -2,7 +2,7 @@
The formatting of the results are controlled in .\formats\vsteamPSDrive.format.ps1xml
Modeling a VSTeam for example:
-
+
Account
- Agent Pools
- Pool1
@@ -12,6 +12,17 @@
- Builds
- Build1
- Build2
+ - Build Definitions
+ - Build Definition 1
+ - Phase 1
+ - Step 1a
+ - Step 1b
+ - Step 1c
+ - Phase 2
+ - Step 2a
+ - Step 2b
+ - Build Definition 2
+ - yamlFileName
- Releases
- Release1
- Environment 1
@@ -48,6 +59,29 @@ Get-ChildItem
using namespace Microsoft.PowerShell.SHiPS
+class VSTeamVersions {
+ static [string] $Account = $env:TEAM_ACCT
+ static [string] $DefaultProject = $env:TEAM_PROJECT
+ static [string] $Version = 'TFS2017'
+ static [string] $Build = '3.0'
+ static [string] $Release = '3.0-preview'
+ static [string] $Core = '3.0'
+ static [string] $Git = '3.0'
+ static [string] $DistributedTask = '3.0-preview'
+ static [string] $Tfvc = '3.0'
+ static [string] $MemberEntitlementManagement = ''
+ static [string] $ServiceFabricEndpoint = ''
+ static [string] $ModuleVersion = $null
+}
+
+# Dynamic parameters get called alot. This can cause
+# multiple calls to TFS/VSTS for a single function call
+# so I am going to try and cache the values.
+class VSTeamProjectCache {
+ static [int] $timestamp = -1
+ static [object] $projects = $null
+}
+
class VSTeamDirectory : SHiPSDirectory {
# The object returned from the REST API call
[object] hidden $_internalObj = $null
@@ -167,7 +201,7 @@ class VSTeamAccount : SHiPSDirectory {
$poolsAndProjects = @(
[VSTeamPools]::new('Agent Pools')
)
-
+
$items = Get-VSTeamProject | Sort-Object Name
foreach ($item in $items) {
@@ -230,6 +264,7 @@ class VSTeamProject : VSTeamDirectory {
[object[]] GetChildItem() {
return @(
+ [VSTeamBuildDefinitions]::new('Build Definitions', $this.Name),
[VSTeamBuilds]::new('Builds', $this.Name),
[VSTeamReleases]::new('Releases', $this.Name),
[VSTeamRepositories]::new('Repositories', $this.Name),
@@ -286,10 +321,16 @@ class VSTeamPool : VSTeamDirectory {
$this.id = $obj.id
$this.count = $obj.size
$this.isHosted = $obj.isHosted
- $this.createdBy = [VSTeamUser]::new($obj.createdBy, $null)
+
+ # On some accounts teh CreatedBy is null for hosted pools
+ if ($null -ne $obj.createdBy) {
+ $this.createdBy = [VSTeamUser]::new($obj.createdBy, $null)
+ }
# Depending on TFS/VSTS this might not be returned
- if ($obj.PSObject.Properties.Match('owner').count -gt 0) {
+ # Just becaues it exisit does not mean it is not $null
+ if ($obj.PSObject.Properties.Match('owner').count -gt 0 -and
+ $null -ne $obj.owner) {
$this.owner = [VSTeamUser]::new($obj.owner, $null)
}
@@ -299,7 +340,7 @@ class VSTeamPool : VSTeamDirectory {
$this.DisplayMode = 'd-r-s-'
}
else {
- $this.DisplayMode = 'd-----'
+ $this.DisplayMode = 'd-----'
}
$this._internalObj = $obj
@@ -407,6 +448,252 @@ class VSTeamBuild : VSTeamLeaf {
}
}
+[SHiPSProvider(UseCache = $true)]
+[SHiPSProvider(BuiltinProgress = $false)]
+class VSTeamBuildDefinitions : VSTeamDirectory {
+
+ # Default constructor
+ VSTeamBuildDefinitions(
+ [string]$Name,
+ [string]$ProjectName
+ ) : base($Name, $ProjectName) {
+ $this.AddTypeName('Team.BuildDefinitions')
+ }
+
+ [object[]] GetChildItem() {
+ $items = Get-VSTeamBuildDefinition -ProjectName $this.ProjectName -ErrorAction SilentlyContinue
+
+ foreach ($item in $items) {
+ $item.AddTypeName('Team.Provider.BuildDefinition')
+
+ # This has to be done here becuase this is the only point
+ # we know if the object graph is for the provider or not.
+ if ($item._internalObj.PSObject.Properties.Match('process').count -gt 0) {
+ if ($item.Process.type -eq 1) {
+ $item.Process.AddTypeName('Team.Provider.BuildDefinitionPhasedProcess')
+ foreach ($phase in $item.Process.phases) {
+ $phase.AddTypeName('Team.Provider.BuildDefinitionProcessPhase')
+
+ foreach ($step in $phase.steps) {
+ $step.AddTypeName('Team.Provider.BuildDefinitionProcessPhaseStep')
+ }
+ }
+ }
+ else {
+ $item.Process.AddTypeName('Team.Provider.BuildDefinitionProcess')
+ }
+ }
+
+
+ # TFS
+ if ($item._internalObj.PSObject.Properties.Match('build').count -gt 0) {
+ foreach ($step in $item.Steps) {
+ $step.AddTypeName('Team.Provider.BuildDefinitionProcessPhaseStep')
+ }
+ }
+ }
+
+ return $items
+ }
+}
+
+[SHiPSProvider(UseCache = $false)]
+[SHiPSProvider(BuiltinProgress = $false)]
+class VSTeamBuildDefinition : VSTeamDirectory {
+
+ [int]$id = -1
+ [int]$Revision = -1
+ [string]$Path = $null
+ [object]$Tags = $null
+ [object]$Queue = $null
+ [object]$Options = $null
+ [object]$Triggers = $null
+ [object]$Variables = $null
+ [object]$Repository = $null
+ [object]$RetentionRules = $null
+ [VSTeamUser]$AuthoredBy = $null
+ [string]$BuildNumberFormat = $null
+ [string]$JobAuthorizationScope = $null
+ [datetime]$CreatedOn = [datetime]::MinValue
+ [VSTeamBuildDefinitionProcess]$Process = $null
+ [VSTeamBuildDefinitionProcessPhaseStep[]]$Steps = $null
+
+ VSTeamBuildDefinition (
+ [object]$obj,
+ [string]$Projectname
+ ) : base($obj.name, $Projectname) {
+
+ $this.id = $obj.id
+ $this.Path = $obj.path
+ $this.Queue = $obj.queue
+ $this.Revision = $obj.revision
+ $this.Variables = $obj.variables
+ $this.CreatedOn = $obj.createdDate
+ $this.Repository = $obj.repository
+ $this.JobAuthorizationScope = $obj.jobAuthorizationScope
+ $this.AuthoredBy = [VSTeamUser]::new($obj.authoredBy, $Projectname)
+
+ # These might not be returned
+ if ($obj.PSObject.Properties.Match('triggers').count -gt 0) {
+ $this.Triggers = $obj.triggers
+ }
+
+ if ($obj.PSObject.Properties.Match('retentionRules').count -gt 0) {
+ $this.RetentionRules = $obj.retentionRules
+ }
+
+ if ($obj.PSObject.Properties.Match('options').count -gt 0) {
+ $this.Options = $obj.options
+ }
+
+ if ($obj.PSObject.Properties.Match('tags').count -gt 0) {
+ $this.Tags = $obj.tags
+ }
+
+ # This is only in VSTS. In TFS it is a build property
+ if ($obj.PSObject.Properties.Match('process').count -gt 0) {
+ $this.Process = [VSTeamBuildDefinitionProcess]::new($obj.process, $Projectname)
+ }
+
+ # TFS 2017/2018
+ if ($obj.PSObject.Properties.Match('build').count -gt 0) {
+ $stepNo = 0
+ foreach ($step in $obj.build) {
+ $stepNo++
+ $this.Steps += [VSTeamBuildDefinitionProcessPhaseStep]::new($step, $stepNo, $Projectname)
+ }
+ }
+
+ if ($obj.PSObject.Properties.Match('BuildNumberFormat').count -gt 0) {
+ $this.BuildNumberFormat = $obj.buildNumberFormat
+ }
+
+ $this._internalObj = $obj
+
+ $this.AddTypeName('Team.BuildDefinition')
+ }
+
+ [object[]] GetChildItem() {
+
+ if ($null -ne $this.Steps) {
+ return $this.Steps
+ }
+
+ if ($this.Process.Type -eq 1) {
+ return $this.Process.Phases
+ }
+ else {
+ return $this.Process
+ }
+ }
+}
+
+[SHiPSProvider(UseCache = $true)]
+class VSTeamBuildDefinitionProcess : VSTeamDirectory {
+ [int]$type
+ [string]$yamlFilename
+ [VSTeamBuildDefinitionProcessPhase[]]$Phases
+
+ VSTeamBuildDefinitionProcess (
+ [object]$obj,
+ [string]$Projectname
+ ) : base("Process", $Projectname) {
+
+ # Is this a yaml build or not?
+ # Type is = 2 for yaml
+ $this.type = $obj.type
+
+ if ($this.type -eq 1) {
+ foreach ($phase in $obj.phases) {
+ $this.Phases += [VSTeamBuildDefinitionProcessPhase]::new($phase, $Projectname)
+ }
+
+ $this.AddTypeName('Team.BuildDefinitionPhasedProcess')
+ }
+ else {
+ $this.yamlFilename = $obj.yamlFilename
+
+ $this.DisplayMode = '------'
+ $this.AddTypeName('Team.BuildDefinitionYamlProcess')
+ }
+
+ $this._internalObj = $obj
+ }
+
+ [string]ToString() {
+ if ($this.type -eq 1) {
+ return "Number of phases: $($this.Phases.Length)"
+ }
+ else {
+ return $this.yamlFilename
+ }
+ }
+}
+
+class VSTeamBuildDefinitionProcessPhase : VSTeamDirectory {
+ [string]$Condition = $null
+ [object]$Target = $null
+ [string]$JobAuthorizationScope = $null
+ [int]$JobCancelTimeoutInMinutes = -1
+ [VSTeamBuildDefinitionProcessPhaseStep[]] $Steps
+ [int]$StepCount = 0
+
+ VSTeamBuildDefinitionProcessPhase(
+ [object]$obj,
+ [string]$Projectname
+ ) : base($obj.name, $Projectname) {
+ $this.Condition = $obj.condition
+ $this.Target = $obj.target
+ $this.JobAuthorizationScope = $obj.jobAuthorizationScope
+ $this.JobCancelTimeoutInMinutes = $obj.jobCancelTimeoutInMinutes
+
+ $this.StepCount = 0
+ foreach ($step in $obj.steps) {
+ $this.StepCount++
+ $this.Steps += [VSTeamBuildDefinitionProcessPhaseStep]::new($step, $this.StepCount, $Projectname)
+ }
+
+ $this._internalObj = $obj
+
+ $this.AddTypeName('Team.BuildDefinitionProcessPhase')
+ }
+
+ [object[]] GetChildItem() {
+ return $this.Steps
+ }
+}
+
+class VSTeamBuildDefinitionProcessPhaseStep : VSTeamLeaf {
+ [bool]$Enabled = $true
+ [bool]$ContinueOnError = $false
+ [bool]$AlwaysRun = $true
+ [int]$TimeoutInMinutes = 0
+ [string]$Condition = $null
+ [object]$Inputs = $null
+ [object]$Task = $null
+
+ VSTeamBuildDefinitionProcessPhaseStep(
+ [object]$obj,
+ [int]$stepNo,
+ [string]$Projectname
+ ) : base($obj.displayName, $stepNo.ToString(), $Projectname) {
+ $this.Enabled = $obj.enabled
+ $this.ContinueOnError = $obj.continueOnError
+ $this.AlwaysRun = $obj.alwaysRun
+ $this.TimeoutInMinutes = $obj.timeoutInMinutes
+ $this.Inputs = $obj.inputs
+ $this.Task = $obj.task
+
+ if ($obj.PSObject.Properties.Match('condition').count -gt 0) {
+ $this.Condition = $obj.condition
+ }
+
+ $this._internalObj = $obj
+
+ $this.AddTypeName('Team.BuildDefinitionProcessPhaseStep')
+ }
+}
+
[SHiPSProvider(UseCache = $true)]
[SHiPSProvider(BuiltinProgress = $false)]
class VSTeamReleases : VSTeamDirectory {
@@ -682,6 +969,7 @@ class VSTeamRef : VSTeamLeaf {
[object]$obj,
[string]$ProjectName
) : base($obj.name, $obj.objectId, $ProjectName) {
+
$this.RefName = $obj.name
$this.Creator = [VSTeamUser]::new($obj.creator, $ProjectName)
diff --git a/src/tfvc.psm1 b/src/tfvc.psm1
index d9962c196..124c111e0 100644
--- a/src/tfvc.psm1
+++ b/src/tfvc.psm1
@@ -28,7 +28,7 @@ function Get-VSTeamTfvcRootBranch {
includeDeleted = $IncludeDeleted;
}
- $resp = _callAPI -Area tfvc -Resource branches -QueryString $queryString -Version $VSTeamVersionTable.Tfvc
+ $resp = _callAPI -Area tfvc -Resource branches -QueryString $queryString -Version $([VSTeamVersions]::Tfvc)
if ($resp | Get-Member -Name value -MemberType Properties) {
foreach ($item in $resp.value) {
@@ -69,7 +69,7 @@ function Get-VSTeamTfvcBranch {
includeDeleted = $IncludeDeleted;
}
- $resp = _callAPI -Area tfvc -Resource branches -Id $item -QueryString $queryString -Version $VSTeamVersionTable.Tfvc
+ $resp = _callAPI -Area tfvc -Resource branches -Id $item -QueryString $queryString -Version $([VSTeamVersions]::Tfvc)
_applyTypesToTfvcBranch -item $resp
diff --git a/src/users.psm1 b/src/users.psm1
index 06e9836b6..9a44bc8d6 100644
--- a/src/users.psm1
+++ b/src/users.psm1
@@ -17,7 +17,7 @@ function _applyTypesToUser {
}
function _supportsMemberEntitlementManagement {
- if (-not $VSTeamVersionTable.MemberEntitlementManagement) {
+ if (-not [VSTeamVersions]::MemberEntitlementManagement) {
throw 'This account does not support Member Entitlement.'
}
}
@@ -48,7 +48,7 @@ function Get-VSTeamUser {
foreach ($item in $Id) {
# Build the url to return the single build
# Call the REST API
- $resp = _callAPI -SubDomain 'vsaex' -Version $VSTeamVersionTable.MemberEntitlementManagement -Resource 'userentitlements' -id $item
+ $resp = _callAPI -SubDomain 'vsaex' -Version $([VSTeamVersions]::MemberEntitlementManagement) -Resource 'userentitlements' -id $item
_applyTypesToUser -item $resp
@@ -59,7 +59,7 @@ function Get-VSTeamUser {
# Build the url to list the teams
# $listurl = _buildUserURL
$listurl = _buildRequestURI -SubDomain 'vsaex' -Resource 'userentitlements' `
- -Version $VSTeamVersionTable.MemberEntitlementManagement
+ -Version $([VSTeamVersions]::MemberEntitlementManagement)
$listurl += _appendQueryString -name "top" -value $top -retainZero
$listurl += _appendQueryString -name "skip" -value $skip -retainZero
@@ -122,7 +122,7 @@ function Add-VSTeamUser {
$body = $obj | ConvertTo-Json
# Call the REST API
- _callAPI -Method Post -Body $body -SubDomain 'vsaex' -Resource 'userentitlements' -Version $VSTeamVersionTable.MemberEntitlementManagement -ContentType "application/json"
+ _callAPI -Method Post -Body $body -SubDomain 'vsaex' -Resource 'userentitlements' -Version $([VSTeamVersions]::MemberEntitlementManagement) -ContentType "application/json"
}
}
@@ -159,7 +159,7 @@ function Remove-VSTeamUser {
if ($Force -or $PSCmdlet.ShouldProcess("$($user.userName) ($($user.email))", "Delete user")) {
# Call the REST API
- _callAPI -Method Delete -SubDomain 'vsaex' -Resource 'userentitlements' -Id $Id -Version $VSTeamVersionTable.MemberEntitlementManagement | Out-Null
+ _callAPI -Method Delete -SubDomain 'vsaex' -Resource 'userentitlements' -Id $Id -Version $([VSTeamVersions]::MemberEntitlementManagement) | Out-Null
Write-Output "Deleted user $($user.userName) ($($user.email))"
}
diff --git a/src/workitemTypes.psm1 b/src/workitemTypes.psm1
index c01a87d19..9610222b2 100644
--- a/src/workitemTypes.psm1
+++ b/src/workitemTypes.psm1
@@ -47,7 +47,7 @@ function Get-VSTeamWorkItemType {
# Call the REST API
if ($WorkItemType) {
$resp = _callAPI -ProjectName $ProjectName -Area 'wit' -Resource 'workitemtypes' `
- -Version $VSTeamVersionTable.Core -id $WorkItemType
+ -Version $([VSTeamVersions]::Core) -id $WorkItemType
# This call returns JSON with "": which causes the ConvertFrom-Json to fail.
# To replace all the "": with "_end":
@@ -59,7 +59,7 @@ function Get-VSTeamWorkItemType {
}
else {
$resp = _callAPI -ProjectName $ProjectName -Area 'wit' -Resource 'workitemtypes' `
- -Version $VSTeamVersionTable.Core
+ -Version $([VSTeamVersions]::Core)
# This call returns JSON with "": which causes the ConvertFrom-Json to fail.
# To replace all the "": with "_end":
diff --git a/src/workitems.psm1 b/src/workitems.psm1
index c4152999c..871fe87e6 100644
--- a/src/workitems.psm1
+++ b/src/workitems.psm1
@@ -57,7 +57,7 @@ function Add-VSTeamWorkItem {
# Call the REST API
$resp = _callAPI -ProjectName $ProjectName -Area 'wit' -Resource 'workitems' `
- -Version $VSTeamVersionTable.Core -id $WorkItemType -Method Post `
+ -Version $([VSTeamVersions]::Core) -id $WorkItemType -Method Post `
-ContentType 'application/json-patch+json' -Body $body
_applyTypesToWorkItem -item $resp
@@ -82,7 +82,7 @@ function Show-VSTeamWorkItem {
# Bind the parameter to a friendly variable
$ProjectName = $PSBoundParameters["ProjectName"]
- Show-Browser "$($VSTeamVersionTable.Account)/$ProjectName/_workitems/edit/$Id"
+ Show-Browser "$([VSTeamVersions]::Account)/$ProjectName/_workitems/edit/$Id"
}
}
@@ -116,7 +116,7 @@ function Get-VSTeamWorkItem {
# Call the REST API
if ($Ids) {
$resp = _callAPI -ProjectName $ProjectName -Area 'wit' -Resource 'workitems' `
- -Version $VSTeamVersionTable.Core `
+ -Version $([VSTeamVersions]::Core) `
-Querystring @{
'$Expand' = $Expand
fields = ($Fields -join ',')
@@ -131,7 +131,7 @@ function Get-VSTeamWorkItem {
else {
$a = $id[0]
$resp = _callAPI -ProjectName $ProjectName -Area 'wit' -Resource 'workitems' `
- -Version $VSTeamVersionTable.Core -id "$a" `
+ -Version $([VSTeamVersions]::Core) -id "$a" `
-Querystring @{
'$Expand' = $Expand
fields = ($Fields -join ',')
diff --git a/types/buildDefinitions.ps1xml b/types/buildDefinitions.ps1xml
deleted file mode 100644
index 6fecde97e..000000000
--- a/types/buildDefinitions.ps1xml
+++ /dev/null
@@ -1,44 +0,0 @@
-
-
-
-
- Team.BuildDefinition
-
-
- authoredByUser
- $this.authoredBy.displayName
-
-
- queueName
- $this.queue.name
-
-
- fullName
-
- if($this.path -eq "\") {
- $temp = $this.path + $this.name
- } else {
- $temp = $this.path + "\" + $this.name
- }
-
- $temp.SubString(1)
-
-
-
- PSStandardMembers
-
-
- DefaultDisplayPropertySet
-
- id
- name
- queueName
- authoredByUser
- path
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/unit/Invokepester.ps1 b/unit/Invokepester.ps1
new file mode 100644
index 000000000..19525671e
--- /dev/null
+++ b/unit/Invokepester.ps1
@@ -0,0 +1,56 @@
+function Invoke-PesterJob {
+ [CmdletBinding(DefaultParameterSetName = 'LegacyOutputXml')]
+ param(
+ [Parameter(Position = 0)]
+ [Alias('Path', 'relative_path')]
+ [System.Object[]]
+ ${Script},
+
+ [Parameter(Position = 1)]
+ [Alias('Name')]
+ [string[]]
+ ${TestName},
+
+ [Parameter(Position = 2)]
+ [switch]
+ ${EnableExit},
+
+ [Parameter(ParameterSetName = 'LegacyOutputXml', Position = 3)]
+ [string]
+ ${OutputXml},
+
+ [Parameter(Position = 4)]
+ [Alias('Tags')]
+ [string[]]
+ ${Tag},
+
+ [string[]]
+ ${ExcludeTag},
+
+ [switch]
+ ${PassThru},
+
+ [System.Object[]]
+ ${CodeCoverage},
+
+ [switch]
+ ${Strict},
+
+ [Parameter(ParameterSetName = 'NewOutputSet', Mandatory = $true)]
+ [string]
+ ${OutputFile},
+
+ [Parameter(ParameterSetName = 'NewOutputSet', Mandatory = $true)]
+ [ValidateSet('LegacyNUnitXml', 'NUnitXml')]
+ [string]
+ ${OutputFormat},
+
+ [switch]
+ ${Quiet}
+ )
+
+ $params = $PSBoundParameters
+
+ Start-Job -ScriptBlock { Set-Location $using:pwd; Invoke-Pester @using:params } |
+ Receive-Job -Wait -AutoRemoveJob
+}
\ No newline at end of file
diff --git a/unit/test/Approvals.Tests.ps1 b/unit/test/Approvals.Tests.ps1
index dde5f3b31..851869a07 100644
--- a/unit/test/Approvals.Tests.ps1
+++ b/unit/test/Approvals.Tests.ps1
@@ -6,7 +6,7 @@ InModuleScope Approvals {
# Set the account to use for testing. A normal user would do this
# using the Add-VSTeamAccount function.
- $VSTeamVersionTable.Account = 'https://test.visualstudio.com'
+ [VSTeamVersions]::Account = 'https://test.visualstudio.com'
Describe 'Approvals' -Tag 'unit', 'approvals' {
# Mock the call to Get-Projects by the dynamic parameter for ProjectName
@@ -15,7 +15,7 @@ InModuleScope Approvals {
}
# Load the mocks to create the project name dynamic parameter
- . "$PSScriptRoot\mockProjectNameDynamicParamNoPSet.ps1"
+ . "$PSScriptRoot\mocks\mockProjectNameDynamicParamNoPSet.ps1"
Context 'Get-VSTeamApproval' {
# Arrange
@@ -56,7 +56,7 @@ InModuleScope Approvals {
# Assert
Assert-MockCalled Invoke-RestMethod -Exactly -Scope Context -Times 1 `
-ParameterFilter {
- $Uri -eq "https://test.vsrm.visualstudio.com/project/_apis/release/approvals/?api-version=$($VSTeamVersionTable.Release)"
+ $Uri -eq "https://test.vsrm.visualstudio.com/project/_apis/release/approvals/?api-version=$([VSTeamVersions]::Release)"
}
}
}
@@ -66,6 +66,8 @@ InModuleScope Approvals {
Mock Invoke-RestMethod {
# If this test fails uncomment the line below to see how the mock was called.
# Write-Host $args
+ # Write-Host $([VSTeamVersions]::Release)
+ # Write-Host $([VSTeamVersions]::Account)
return @{
count = 1
@@ -92,11 +94,11 @@ InModuleScope Approvals {
# matches I have to search for the portions I expect but can't
# assume the order.
# The general string should look like this:
- # "https://test.vsrm.visualstudio.com/project/_apis/release/approvals/?api-version=$($VSTeamVersionTable.Release)&assignedtoFilter=Chuck%20Reinhart&includeMyGroupApprovals=true"
+ # "https://test.vsrm.visualstudio.com/project/_apis/release/approvals/?api-version=$([VSTeamVersions]::Release)&assignedtoFilter=Chuck%20Reinhart&includeMyGroupApprovals=true"
Assert-MockCalled Invoke-RestMethod -Exactly -Scope Context -Times 1 `
-ParameterFilter {
$Uri -like "*https://test.vsrm.visualstudio.com/project/_apis/release/approvals/*" -and
- $Uri -like "*api-version=$($VSTeamVersionTable.Release)*" -and
+ $Uri -like "*api-version=$([VSTeamVersions]::Release)*" -and
$Uri -like "*assignedtoFilter=Chuck Reinhart*" -and
$Uri -like "*includeMyGroupApprovals=true*"
}
@@ -125,7 +127,7 @@ InModuleScope Approvals {
It 'should return approvals' {
Assert-MockCalled Invoke-RestMethod -Exactly -Scope Context -Times 1 `
-ParameterFilter {
- $Uri -eq "https://test.vsrm.visualstudio.com/project/_apis/release/approvals/?api-version=$($VSTeamVersionTable.Release)"
+ $Uri -eq "https://test.vsrm.visualstudio.com/project/_apis/release/approvals/?api-version=$([VSTeamVersions]::Release)"
}
}
}
@@ -146,7 +148,7 @@ InModuleScope Approvals {
Assert-MockCalled Invoke-RestMethod -Exactly -Scope Context -Times 1 `
-ParameterFilter {
$Method -eq 'Patch' -and
- $Uri -eq "https://test.vsrm.visualstudio.com/project/_apis/release/approvals/1?api-version=$($VSTeamVersionTable.Release)"
+ $Uri -eq "https://test.vsrm.visualstudio.com/project/_apis/release/approvals/1?api-version=$([VSTeamVersions]::Release)"
}
}
}
@@ -160,7 +162,7 @@ InModuleScope Approvals {
It 'should set approval' {
Assert-MockCalled Invoke-RestMethod -Exactly -Scope Context -Times 1 `
-ParameterFilter {
- $Uri -eq "https://test.vsrm.visualstudio.com/project/_apis/release/approvals/1?api-version=$($VSTeamVersionTable.Release)"
+ $Uri -eq "https://test.vsrm.visualstudio.com/project/_apis/release/approvals/1?api-version=$([VSTeamVersions]::Release)"
}
}
}
@@ -182,7 +184,7 @@ InModuleScope Approvals {
Assert-MockCalled Invoke-RestMethod -Exactly -Scope Context -Times 1 `
-ParameterFilter {
$Method -eq 'Patch' -and
- $Uri -eq "https://test.vsrm.visualstudio.com/project/_apis/release/approvals/1?api-version=$($VSTeamVersionTable.Release)"
+ $Uri -eq "https://test.vsrm.visualstudio.com/project/_apis/release/approvals/1?api-version=$([VSTeamVersions]::Release)"
}
}
}
@@ -198,7 +200,7 @@ InModuleScope Approvals {
}
Context 'Get-VSTeamApproval TFS' {
- $VSTeamVersionTable.Account = 'http://localhost:8080/tfs/defaultcollection'
+ [VSTeamVersions]::Account = 'http://localhost:8080/tfs/defaultcollection'
Mock Invoke-RestMethod {
# If this test fails uncomment the line below to see how the mock was called.
@@ -226,11 +228,11 @@ InModuleScope Approvals {
# matches I have to search for the portions I expect but can't
# assume the order.
# The general string should look like this:
- # "http://localhost:8080/tfs/defaultcollection/project/_apis/release/approvals/?api-version=$($VSTeamVersionTable.Release)&statusFilter=Pending&assignedtoFilter=Test User&includeMyGroupApprovals=true&releaseIdsFilter=1"
+ # "http://localhost:8080/tfs/defaultcollection/project/_apis/release/approvals/?api-version=$([VSTeamVersions]::Release)&statusFilter=Pending&assignedtoFilter=Test User&includeMyGroupApprovals=true&releaseIdsFilter=1"
Assert-MockCalled Invoke-RestMethod -Exactly -Scope Context -Times 1 `
-ParameterFilter {
$Uri -like "*http://localhost:8080/tfs/defaultcollection/project/_apis/release/approvals/*" -and
- $Uri -like "*api-version=$($VSTeamVersionTable.Release)*" -and
+ $Uri -like "*api-version=$([VSTeamVersions]::Release)*" -and
$Uri -like "*statusFilter=Pending*" -and
$Uri -like "*assignedtoFilter=Test User*" -and
$Uri -like "*includeMyGroupApprovals=true*" -and
diff --git a/unit/test/agents.Tests.ps1 b/unit/test/agents.Tests.ps1
index 3127af412..5159d721e 100644
--- a/unit/test/agents.Tests.ps1
+++ b/unit/test/agents.Tests.ps1
@@ -1,8 +1,8 @@
Set-StrictMode -Version Latest
InModuleScope agents {
- $VSTeamVersionTable.Account = 'https://test.visualstudio.com'
- $VSTeamVersionTable.DistributedTask = '1.0-unitTest'
+ [VSTeamVersions]::Account = 'https://test.visualstudio.com'
+ [VSTeamVersions]::DistributedTask = '1.0-unitTest'
$testAgent = [PSCustomObject]@{
_links = [PSCustomObject]@{}
@@ -35,7 +35,7 @@ InModuleScope agents {
Get-VSTeamAgent -PoolId 1
Assert-MockCalled Invoke-RestMethod -Exactly -Scope It -Times 1 -ParameterFilter {
- $Uri -eq "https://test.visualstudio.com/_apis/distributedtask/pools/1/agents/?api-version=$($VSTeamVersionTable.DistributedTask)"
+ $Uri -eq "https://test.visualstudio.com/_apis/distributedtask/pools/1/agents/?api-version=$([VSTeamVersions]::DistributedTask)"
}
}
}
@@ -51,7 +51,7 @@ InModuleScope agents {
1 | Get-VSTeamAgent
Assert-MockCalled Invoke-RestMethod -Exactly -Scope It -Times 1 -ParameterFilter {
- $Uri -eq "https://test.visualstudio.com/_apis/distributedtask/pools/1/agents/?api-version=$($VSTeamVersionTable.DistributedTask)"
+ $Uri -eq "https://test.visualstudio.com/_apis/distributedtask/pools/1/agents/?api-version=$([VSTeamVersions]::DistributedTask)"
}
}
}
@@ -63,7 +63,7 @@ InModuleScope agents {
Get-VSTeamAgent -PoolId 1 -id 1
Assert-MockCalled Invoke-RestMethod -Exactly -Scope It -Times 1 -ParameterFilter {
- $Uri -eq "https://test.visualstudio.com/_apis/distributedtask/pools/1/agents/1?api-version=$($VSTeamVersionTable.DistributedTask)"
+ $Uri -eq "https://test.visualstudio.com/_apis/distributedtask/pools/1/agents/1?api-version=$([VSTeamVersions]::DistributedTask)"
}
}
}
@@ -76,7 +76,7 @@ InModuleScope agents {
Assert-MockCalled Invoke-RestMethod -Exactly -Scope It -Times 1 -ParameterFilter {
$Method -eq 'Delete' -and
- $Uri -eq "https://test.visualstudio.com/_apis/distributedtask/pools/36/agents/950?api-version=$($VSTeamVersionTable.DistributedTask)"
+ $Uri -eq "https://test.visualstudio.com/_apis/distributedtask/pools/36/agents/950?api-version=$([VSTeamVersions]::DistributedTask)"
}
}
}
@@ -97,7 +97,7 @@ InModuleScope agents {
Assert-MockCalled Invoke-RestMethod -Exactly -Scope It -Times 1 -ParameterFilter {
$Method -eq 'Patch' -and
- $Uri -eq "https://test.visualstudio.com/_apis/distributedtask/pools/36/agents/950?api-version=$($VSTeamVersionTable.DistributedTask)"
+ $Uri -eq "https://test.visualstudio.com/_apis/distributedtask/pools/36/agents/950?api-version=$([VSTeamVersions]::DistributedTask)"
}
}
}
@@ -118,7 +118,7 @@ InModuleScope agents {
Assert-MockCalled Invoke-RestMethod -Exactly -Scope It -Times 1 -ParameterFilter {
$Method -eq 'Patch' -and
- $Uri -eq "https://test.visualstudio.com/_apis/distributedtask/pools/36/agents/950?api-version=$($VSTeamVersionTable.DistributedTask)"
+ $Uri -eq "https://test.visualstudio.com/_apis/distributedtask/pools/36/agents/950?api-version=$([VSTeamVersions]::DistributedTask)"
}
}
}
diff --git a/unit/test/buildDefinitions.Tests.ps1 b/unit/test/buildDefinitions.Tests.ps1
index f7ef7c67b..a79c02fa3 100644
--- a/unit/test/buildDefinitions.Tests.ps1
+++ b/unit/test/buildDefinitions.Tests.ps1
@@ -4,18 +4,12 @@ Set-StrictMode -Version Latest
Add-Type -AssemblyName 'System.Web'
InModuleScope buildDefinitions {
- $VSTeamVersionTable.Account = 'https://test.visualstudio.com'
-
- $results = [PSCustomObject]@{
- value = [PSCustomObject]@{
- queue = [PSCustomObject]@{ name = 'Default' }
- _links = [PSCustomObject]@{}
- variables = [PSCustomObject]@{}
- repository = [PSCustomObject]@{}
- project = [PSCustomObject]@{ name = 'project' }
- authoredBy = [PSCustomObject]@{ name = 'test'}
- }
- }
+ [VSTeamVersions]::Account = 'https://test.visualstudio.com'
+
+ $resultsVSTS = Get-Content "$PSScriptRoot\sampleFiles\buildDefvsts.json" -Raw | ConvertFrom-Json
+ $results2017 = Get-Content "$PSScriptRoot\sampleFiles\buildDef2017.json" -Raw | ConvertFrom-Json
+ $results2018 = Get-Content "$PSScriptRoot\sampleFiles\buildDef2018.json" -Raw | ConvertFrom-Json
+ $resultsyaml = Get-Content "$PSScriptRoot\sampleFiles\buildDefyaml.json" -Raw | ConvertFrom-Json
Describe 'BuildDefinitions' {
# Mock the call to Get-Projects by the dynamic parameter for ProjectName
@@ -23,7 +17,7 @@ InModuleScope buildDefinitions {
$Uri -like "*_apis/projects*"
}
- . "$PSScriptRoot\mockProjectNameDynamicParamNoPSet.ps1"
+ . "$PSScriptRoot\mocks\mockProjectNameDynamicParamNoPSet.ps1"
Context 'Show-VSTeamBuildDefinition by ID' {
Mock Show-Browser { }
@@ -97,44 +91,102 @@ InModuleScope buildDefinitions {
}
}
- Context 'Get-VSTeamBuildDefinition with no parameters' {
+ Context 'Get-VSTeamBuildDefinition with no parameters 2017' {
+ Mock _useWindowsAuthenticationOnPremise { return $true }
+ Mock Invoke-RestMethod {
+ # If this test fails uncomment the line below to see how the mock was called.
+ # Write-Host $args
+ # Write-Host $([VSTeamVersions]::Build)
+ # Write-Host $([VSTeamVersions]::Account)
+
+ return $results2017
+ }
+
+ It 'should return build definitions' {
+ Get-VSTeamBuildDefinition -projectName project
+
+ Assert-MockCalled Invoke-RestMethod -Exactly -Scope It -Times 1 -ParameterFilter {
+ $Uri -like "*https://test.visualstudio.com/project/_apis/build/definitions/*" -and
+ $Uri -like "*api-version=$([VSTeamVersions]::Build)*" -and
+ $Uri -like "*type=All*"
+ }
+ }
+ }
+
+ Context 'Get-VSTeamBuildDefinition with no parameters 2018' {
Mock _useWindowsAuthenticationOnPremise { return $true }
Mock Invoke-RestMethod {
- return $results
+ return $results2018
+ }
+
+ It 'should return build definitions' {
+ Get-VSTeamBuildDefinition -projectName project
+
+ Assert-MockCalled Invoke-RestMethod -Exactly -Scope It -Times 1 -ParameterFilter {
+ $Uri -like "*https://test.visualstudio.com/project/_apis/build/definitions/*" -and
+ $Uri -like "*api-version=$([VSTeamVersions]::Build)*" -and
+ $Uri -like "*type=All*"
+ }
+ }
+ }
+
+ Context 'Get-VSTeamBuildDefinition with no parameters VSTS' {
+ Mock Invoke-RestMethod {
+ return $resultsVSTS
+ }
+
+ It 'should return build definitions' {
+ Get-VSTeamBuildDefinition -projectName project
+
+ Assert-MockCalled Invoke-RestMethod -Exactly -Scope It -Times 1 -ParameterFilter {
+ $Uri -like "*https://test.visualstudio.com/project/_apis/build/definitions/*" -and
+ $Uri -like "*api-version=$([VSTeamVersions]::Build)*" -and
+ $Uri -like "*type=All*"
+ }
+ }
+ }
+
+ Context 'Get-VSTeamBuildDefinition with no parameters VSTS yaml ' {
+ Mock Invoke-RestMethod {
+ return $resultsVSTS
}
It 'should return build definitions' {
Get-VSTeamBuildDefinition -projectName project
Assert-MockCalled Invoke-RestMethod -Exactly -Scope It -Times 1 -ParameterFilter {
- $Uri -eq "https://test.visualstudio.com/project/_apis/build/definitions/?api-version=$($VSTeamVersionTable.Build)&type=All"
+ $Uri -like "*https://test.visualstudio.com/project/_apis/build/definitions/*" -and
+ $Uri -like "*api-version=$([VSTeamVersions]::Build)*" -and
+ $Uri -like "*type=All*"
}
}
}
Context 'Get-VSTeamBuildDefinition with type parameter' {
Mock Invoke-RestMethod {
- return $results
+ return $resultsVSTS
}
It 'should return build definitions by type' {
Get-VSTeamBuildDefinition -projectName project -type build
Assert-MockCalled Invoke-RestMethod -Exactly -Scope It -Times 1 -ParameterFilter {
- $Uri -eq "https://test.visualstudio.com/project/_apis/build/definitions/?api-version=$($VSTeamVersionTable.Build)&type=build"
+ $Uri -like "*https://test.visualstudio.com/project/_apis/build/definitions/*" -and
+ $Uri -like "*api-version=$([VSTeamVersions]::Build)*" -and
+ $Uri -like "*type=build*"
}
}
}
Context 'Get-VSTeamBuildDefinition with filter parameter' {
- Mock Invoke-RestMethod { return $results }
+ Mock Invoke-RestMethod { return $resultsVSTS }
It 'should return build definitions by filter' {
Get-VSTeamBuildDefinition -projectName project -filter 'click*'
Assert-MockCalled Invoke-RestMethod -Exactly -Scope It -Times 1 -ParameterFilter {
$Uri -like "*https://test.visualstudio.com/project/_apis/build/definitions/*" -and
- $Uri -like "*api-version=$($VSTeamVersionTable.Build)*" -and
+ $Uri -like "*api-version=$([VSTeamVersions]::Build)*" -and
$Uri -like "*name=click*" -and
$Uri -like "*type=All*"
}
@@ -142,14 +194,14 @@ InModuleScope buildDefinitions {
}
Context 'Get-VSTeamBuildDefinition with both parameters' {
- Mock Invoke-RestMethod { return $results }
+ Mock Invoke-RestMethod { return $resultsVSTS }
It 'should return build definitions by filter' {
Get-VSTeamBuildDefinition -projectName project -filter 'click*' -type build
Assert-MockCalled Invoke-RestMethod -Exactly -Scope It -Times 1 -ParameterFilter {
$Uri -like "*https://test.visualstudio.com/project/_apis/build/definitions/*" -and
- $Uri -like "*api-version=$($VSTeamVersionTable.Build)*" -and
+ $Uri -like "*api-version=$([VSTeamVersions]::Build)*" -and
$Uri -like "*name=click*" -and
$Uri -like "*type=build*"
}
@@ -157,106 +209,87 @@ InModuleScope buildDefinitions {
}
Context 'Add-VSTeamBuildDefinition' {
- Mock Invoke-RestMethod { return $results }
+ Mock Invoke-RestMethod { return $resultsVSTS }
it 'Should add build' {
- Add-VSTeamBuildDefinition -projectName project -inFile 'builddef.json'
+ Add-VSTeamBuildDefinition -projectName project -inFile 'sampleFiles/builddef.json'
Assert-MockCalled Invoke-RestMethod -Exactly -Scope It -Times 1 -ParameterFilter {
$Method -eq 'Post' -and
- $InFile -eq 'builddef.json' -and
- $Uri -eq "https://test.visualstudio.com/project/_apis/build/definitions/?api-version=$($VSTeamVersionTable.Build)"
+ $InFile -eq 'sampleFiles/builddef.json' -and
+ $Uri -eq "https://test.visualstudio.com/project/_apis/build/definitions/?api-version=$([VSTeamVersions]::Build)"
}
}
}
Context 'Get-VSTeamBuildDefinition by ID' {
- Mock Invoke-RestMethod { return @{
- queue = @{}
- _links = @{}
- project = @{}
- variables = @{}
- repository = @{}
- authoredBy = @{}
- }}
+ Mock Invoke-RestMethod { return $resultsVSTS.value }
It 'should return build definition' {
Get-VSTeamBuildDefinition -projectName project -id 15
Assert-MockCalled Invoke-RestMethod -Exactly -Scope It -Times 1 -ParameterFilter {
- $Uri -eq "https://test.visualstudio.com/project/_apis/build/definitions/15?api-version=$($VSTeamVersionTable.Build)"
+ $Uri -eq "https://test.visualstudio.com/project/_apis/build/definitions/15?api-version=$([VSTeamVersions]::Build)"
}
}
}
Context 'Get-VSTeamBuildDefinition by ID local auth' {
Mock _useWindowsAuthenticationOnPremise { return $true }
- Mock Invoke-RestMethod { return [PSCustomObject]@{
- queue = [PSCustomObject]@{}
- _links = [PSCustomObject]@{}
- project = [PSCustomObject]@{}
- variables = [PSCustomObject]@{}
- repository = [PSCustomObject]@{}
- authoredBy = [PSCustomObject]@{}
- }}
+ Mock Invoke-RestMethod { return $resultsVSTS.value }
It 'should return build definition' {
Get-VSTeamBuildDefinition -projectName project -id 15
Assert-MockCalled Invoke-RestMethod -Exactly -Scope It -Times 1 -ParameterFilter {
- $Uri -eq "https://test.visualstudio.com/project/_apis/build/definitions/15?api-version=$($VSTeamVersionTable.Build)"
+ $Uri -eq "https://test.visualstudio.com/project/_apis/build/definitions/15?api-version=$([VSTeamVersions]::Build)"
}
}
}
Context 'Get-VSTeamBuildDefinition with revision parameter' {
- Mock Invoke-RestMethod { return @{
- queue = @{}
- _links = @{}
- project = @{}
- authoredBy = @{}
- }}
+ Mock Invoke-RestMethod { return $resultsVSTS.value }
It 'should return build definitions by revision' {
Get-VSTeamBuildDefinition -projectName project -id 16 -revision 1
Assert-MockCalled Invoke-RestMethod -Exactly -Scope It -Times 1 -ParameterFilter {
- $Uri -eq "https://test.visualstudio.com/project/_apis/build/definitions/16?api-version=$($VSTeamVersionTable.Build)&revision=1"
+ $Uri -eq "https://test.visualstudio.com/project/_apis/build/definitions/16?api-version=$([VSTeamVersions]::Build)&revision=1"
}
}
}
Context 'Remove-VSTeamBuildDefinition' {
- Mock Invoke-RestMethod { return $results }
+ Mock Invoke-RestMethod { return $resultsVSTS }
It 'should delete build definition' {
Remove-VSTeamBuildDefinition -projectName project -id 2 -Force
Assert-MockCalled Invoke-RestMethod -Exactly -Scope It -Times 1 -ParameterFilter {
$Method -eq 'Delete' -and
- $Uri -eq "https://test.visualstudio.com/project/_apis/build/definitions/2?api-version=$($VSTeamVersionTable.Build)"
+ $Uri -eq "https://test.visualstudio.com/project/_apis/build/definitions/2?api-version=$([VSTeamVersions]::Build)"
}
}
}
Context 'Update-VSTeamBuildDefinition' {
- Mock Invoke-RestMethod { return $results }
+ Mock Invoke-RestMethod { return $resultsVSTS }
It 'should update build definition' {
- Update-VSTeamBuildDefinition -projectName project -id 2 -inFile 'builddef.json' -Force
+ Update-VSTeamBuildDefinition -projectName project -id 2 -inFile 'sampleFiles/builddef.json' -Force
Assert-MockCalled Invoke-RestMethod -Exactly -Scope It -Times 1 -ParameterFilter {
$Method -eq 'Put' -and
- $InFile -eq 'builddef.json' -and
- $Uri -eq "https://test.visualstudio.com/project/_apis/build/definitions/2?api-version=$($VSTeamVersionTable.Build)"
+ $InFile -eq 'sampleFiles/builddef.json' -and
+ $Uri -eq "https://test.visualstudio.com/project/_apis/build/definitions/2?api-version=$([VSTeamVersions]::Build)"
}
}
}
# Make sure these test run last as the need differnt
- # $VSTeamVersionTable.Account values
+ # [VSTeamVersions]::Account values
Context 'Get-VSTeamBuildDefinition with no account' {
- $VSTeamVersionTable.Account = $null
+ [VSTeamVersions]::Account = $null
It 'should return build definitions' {
{ Get-VSTeamBuildDefinition -projectName project } | Should Throw
@@ -264,48 +297,48 @@ InModuleScope buildDefinitions {
}
Context 'Add-VSTeamBuildDefinition on TFS local Auth' {
- Mock Invoke-RestMethod { return $results }
+ Mock Invoke-RestMethod { return $resultsVSTS }
Mock _useWindowsAuthenticationOnPremise { return $true }
- $VSTeamVersionTable.Account = 'http://localhost:8080/tfs/defaultcollection'
+ [VSTeamVersions]::Account = 'http://localhost:8080/tfs/defaultcollection'
it 'Should add build' {
- Add-VSTeamBuildDefinition -projectName project -inFile 'builddef.json'
+ Add-VSTeamBuildDefinition -projectName project -inFile 'sampleFiles/builddef.json'
Assert-MockCalled Invoke-RestMethod -Exactly -Scope It -Times 1 -ParameterFilter {
$Method -eq 'Post' -and
- $InFile -eq 'builddef.json' -and
- $Uri -eq "http://localhost:8080/tfs/defaultcollection/project/_apis/build/definitions/?api-version=$($VSTeamVersionTable.Build)"
+ $InFile -eq 'sampleFiles/builddef.json' -and
+ $Uri -eq "http://localhost:8080/tfs/defaultcollection/project/_apis/build/definitions/?api-version=$([VSTeamVersions]::Build)"
}
}
}
Context 'Remove-VSTeamBuildDefinition on TFS local Auth' {
- Mock Invoke-RestMethod { return $results }
+ Mock Invoke-RestMethod { return $resultsVSTS }
Mock _useWindowsAuthenticationOnPremise { return $true }
- $VSTeamVersionTable.Account = 'http://localhost:8080/tfs/defaultcollection'
+ [VSTeamVersions]::Account = 'http://localhost:8080/tfs/defaultcollection'
Remove-VSTeamBuildDefinition -projectName project -id 2 -Force
It 'should delete build definition' {
Assert-MockCalled Invoke-RestMethod -Exactly -Scope Context -Times 1 -ParameterFilter {
$Method -eq 'Delete' -and
- $Uri -eq "http://localhost:8080/tfs/defaultcollection/project/_apis/build/definitions/2?api-version=$($VSTeamVersionTable.Build)"
+ $Uri -eq "http://localhost:8080/tfs/defaultcollection/project/_apis/build/definitions/2?api-version=$([VSTeamVersions]::Build)"
}
}
}
Context 'Update-VSTeamBuildDefinition on TFS local Auth' {
- Mock Invoke-RestMethod { return $results }
+ Mock Invoke-RestMethod { return $resultsVSTS }
Mock _useWindowsAuthenticationOnPremise { return $true }
- $VSTeamVersionTable.Account = 'http://localhost:8080/tfs/defaultcollection'
+ [VSTeamVersions]::Account = 'http://localhost:8080/tfs/defaultcollection'
- Update-VSTeamBuildDefinition -projectName project -id 2 -inFile 'builddef.json' -Force
+ Update-VSTeamBuildDefinition -projectName project -id 2 -inFile 'sampleFiles/builddef.json' -Force
It 'should update build definition' {
Assert-MockCalled Invoke-RestMethod -Exactly -Scope Context -Times 1 -ParameterFilter {
$Method -eq 'Put' -and
- $InFile -eq 'builddef.json' -and
- $Uri -eq "http://localhost:8080/tfs/defaultcollection/project/_apis/build/definitions/2?api-version=$($VSTeamVersionTable.Build)"
+ $InFile -eq 'sampleFiles/builddef.json' -and
+ $Uri -eq "http://localhost:8080/tfs/defaultcollection/project/_apis/build/definitions/2?api-version=$([VSTeamVersions]::Build)"
}
}
}
diff --git a/unit/test/builds.Tests.ps1 b/unit/test/builds.Tests.ps1
index 588b196d0..2cfecd7b8 100644
--- a/unit/test/builds.Tests.ps1
+++ b/unit/test/builds.Tests.ps1
@@ -51,11 +51,11 @@ InModuleScope builds {
Describe 'Builds VSTS' {
# Load the mocks to create the project name dynamic parameter
- . "$PSScriptRoot\mockProjectNameDynamicParamNoPSet.ps1"
+ . "$PSScriptRoot\mocks\mockProjectNameDynamicParamNoPSet.ps1"
# Set the account to use for testing. A normal user would do this
# using the Add-VSTeamAccount function.
- $VSTeamVersionTable.Account = 'https://test.visualstudio.com'
+ [VSTeamVersions]::Account = 'https://test.visualstudio.com'
# Mock the call to Get-Projects by the dynamic parameter for ProjectName
Mock Invoke-RestMethod { return @() } -ParameterFilter {
@@ -71,7 +71,7 @@ InModuleScope builds {
Assert-MockCalled Invoke-RestMethod -Exactly -Scope Context -Times 1 -ParameterFilter {
$Method -eq 'Patch' -and
$Body -eq '{"keepForever": true}' -and
- $Uri -eq "https://test.visualstudio.com/project/_apis/build/builds/1?api-version=$($VSTeamVersionTable.Build)" }
+ $Uri -eq "https://test.visualstudio.com/project/_apis/build/builds/1?api-version=$([VSTeamVersions]::Build)" }
}
}
@@ -87,10 +87,10 @@ InModuleScope builds {
Context 'Get Build Log with build id' {
Mock Invoke-RestMethod { return @{ count = 4 } } -Verifiable -ParameterFilter {
- $Uri -eq "https://test.visualstudio.com/project/_apis/build/builds/1/logs/?api-version=$($VSTeamVersionTable.Build)"
+ $Uri -eq "https://test.visualstudio.com/project/_apis/build/builds/1/logs/?api-version=$([VSTeamVersions]::Build)"
}
Mock Invoke-RestMethod { return @{ value = @{} } } -Verifiable -ParameterFilter {
- $Uri -eq "https://test.visualstudio.com/project/_apis/build/builds/1/logs/3?api-version=$($VSTeamVersionTable.Build)"
+ $Uri -eq "https://test.visualstudio.com/project/_apis/build/builds/1/logs/3?api-version=$([VSTeamVersions]::Build)"
}
Mock Invoke-RestMethod { throw 'Invoke-RestMethod called with wrong URL' }
@@ -102,7 +102,7 @@ InModuleScope builds {
}
Context 'Get Build Log with build id and index' {
- Mock Invoke-RestMethod { return @{ value = @{} } } -Verifiable -ParameterFilter { $Uri -eq "https://test.visualstudio.com/project/_apis/build/builds/1/logs/2?api-version=$($VSTeamVersionTable.Build)" }
+ Mock Invoke-RestMethod { return @{ value = @{} } } -Verifiable -ParameterFilter { $Uri -eq "https://test.visualstudio.com/project/_apis/build/builds/1/logs/2?api-version=$([VSTeamVersions]::Build)" }
Mock Invoke-RestMethod { throw 'Invoke-RestMethod called with wrong URL' }
Get-VSTeamBuildLog -projectName project -Id 1 -Index 2
@@ -119,7 +119,7 @@ InModuleScope builds {
Get-VSTeamBuild -projectName project
Assert-MockCalled Invoke-RestMethod -Exactly -Scope It -Times 1 -ParameterFilter {
- $Uri -eq "https://test.visualstudio.com/project/_apis/build/builds/?api-version=$($VSTeamVersionTable.Build)"
+ $Uri -eq "https://test.visualstudio.com/project/_apis/build/builds/?api-version=$([VSTeamVersions]::Build)"
}
}
}
@@ -131,7 +131,7 @@ InModuleScope builds {
Get-VSTeamBuild -projectName project -top 1
Assert-MockCalled Invoke-RestMethod -Exactly -Scope It -Times 1 -ParameterFilter {
- $Uri -eq "https://test.visualstudio.com/project/_apis/build/builds/?api-version=$($VSTeamVersionTable.Build)&`$top=1"
+ $Uri -eq "https://test.visualstudio.com/project/_apis/build/builds/?api-version=$([VSTeamVersions]::Build)&`$top=1"
}
}
}
@@ -143,7 +143,7 @@ InModuleScope builds {
It 'should return top builds' {
Assert-MockCalled Invoke-RestMethod -Exactly -Scope Context -Times 1 -ParameterFilter {
- $Uri -eq "https://test.visualstudio.com/project/_apis/build/builds/1?api-version=$($VSTeamVersionTable.Build)"
+ $Uri -eq "https://test.visualstudio.com/project/_apis/build/builds/1?api-version=$([VSTeamVersions]::Build)"
}
}
}
@@ -157,7 +157,7 @@ InModuleScope builds {
# Call to queue build.
Assert-MockCalled Invoke-RestMethod -Exactly -Scope It -Times 1 -ParameterFilter {
($Body | ConvertFrom-Json).definition.id -eq 2 -and
- $Uri -eq "https://test.visualstudio.com/project/_apis/build/builds/?api-version=$($VSTeamVersionTable.Build)"
+ $Uri -eq "https://test.visualstudio.com/project/_apis/build/builds/?api-version=$([VSTeamVersions]::Build)"
}
}
}
@@ -173,7 +173,7 @@ InModuleScope builds {
# Call to queue build.
Assert-MockCalled Invoke-RestMethod -Exactly -Scope It -Times 1 -ParameterFilter {
($Body | ConvertFrom-Json).definition.id -eq 2 -and
- $Uri -eq "https://test.visualstudio.com/project/_apis/build/builds/?api-version=$($VSTeamVersionTable.Build)"
+ $Uri -eq "https://test.visualstudio.com/project/_apis/build/builds/?api-version=$([VSTeamVersions]::Build)"
}
}
}
@@ -190,7 +190,7 @@ InModuleScope builds {
Assert-MockCalled Invoke-RestMethod -Exactly -Scope It -Times 1 -ParameterFilter {
($Body | ConvertFrom-Json).definition.id -eq 2 -and
($Body | ConvertFrom-Json).sourceBranch -eq 'refs/heads/dev' -and
- $Uri -eq "https://test.visualstudio.com/project/_apis/build/builds/?api-version=$($VSTeamVersionTable.Build)"
+ $Uri -eq "https://test.visualstudio.com/project/_apis/build/builds/?api-version=$([VSTeamVersions]::Build)"
}
}
}
@@ -207,7 +207,7 @@ InModuleScope builds {
Assert-MockCalled Invoke-RestMethod -Exactly -Scope It -Times 1 -ParameterFilter {
($Body | ConvertFrom-Json).definition.id -eq 2 -and
(($Body | ConvertFrom-Json).parameters | ConvertFrom-Json).'system.debug' -eq 'true' -and
- $Uri -eq "https://test.visualstudio.com/project/_apis/build/builds/?api-version=$($VSTeamVersionTable.Build)"
+ $Uri -eq "https://test.visualstudio.com/project/_apis/build/builds/?api-version=$([VSTeamVersions]::Build)"
}
}
}
@@ -225,7 +225,7 @@ InModuleScope builds {
# Assert
Assert-MockCalled Invoke-RestMethod -Exactly -Times 1 -ParameterFilter {
$Method -eq 'Delete' -and
- $Uri -eq "https://test.visualstudio.com/project/_apis/build/builds/2?api-version=$($VSTeamVersionTable.Build)"
+ $Uri -eq "https://test.visualstudio.com/project/_apis/build/builds/2?api-version=$([VSTeamVersions]::Build)"
}
}
}
@@ -240,7 +240,7 @@ InModuleScope builds {
foreach ($inputTag in $inputTags) {
Assert-MockCalled Invoke-RestMethod -Exactly -Scope It -Times 1 -ParameterFilter {
$Method -eq 'Put' -and
- $Uri -eq "https://test.visualstudio.com/project/_apis/build/builds/2/tags/?api-version=$($VSTeamVersionTable.Build)" + "&tag=$inputTag"
+ $Uri -eq "https://test.visualstudio.com/project/_apis/build/builds/2/tags/?api-version=$([VSTeamVersions]::Build)" + "&tag=$inputTag"
}
}
}
@@ -258,7 +258,7 @@ InModuleScope builds {
foreach ($inputTag in $inputTags) {
Assert-MockCalled Invoke-RestMethod -Exactly -Scope It -Times 1 -ParameterFilter {
$Method -eq 'Delete' -and
- $Uri -eq "https://test.visualstudio.com/project/_apis/build/builds/2/tags/?api-version=$($VSTeamVersionTable.Build)" + "&tag=$inputTag"
+ $Uri -eq "https://test.visualstudio.com/project/_apis/build/builds/2/tags/?api-version=$([VSTeamVersions]::Build)" + "&tag=$inputTag"
}
}
}
@@ -273,7 +273,7 @@ InModuleScope builds {
Get-VSTeamBuildTag -projectName project -id 2
Assert-MockCalled Invoke-RestMethod -Exactly -Scope It -Times 1 -ParameterFilter {
- $Uri -eq "https://test.visualstudio.com/project/_apis/build/builds/2/tags/?api-version=$($VSTeamVersionTable.Build)"
+ $Uri -eq "https://test.visualstudio.com/project/_apis/build/builds/2/tags/?api-version=$([VSTeamVersions]::Build)"
}
}
}
@@ -310,14 +310,14 @@ InModuleScope builds {
It 'should return the build artifact data' {
Assert-MockCalled Invoke-RestMethod -Exactly -Scope Context -Times 1 -ParameterFilter {
- $Uri -eq "https://test.visualstudio.com/project/_apis/build/builds/2/artifacts/?api-version=$($VSTeamVersionTable.Build)"
+ $Uri -eq "https://test.visualstudio.com/project/_apis/build/builds/2/artifacts/?api-version=$([VSTeamVersions]::Build)"
}
}
}
}
Describe 'Builds TFS' {
- . "$PSScriptRoot\mockProjectNameDynamicParam.ps1"
+ . "$PSScriptRoot\mocks\mockProjectNameDynamicParam.ps1"
Mock _useWindowsAuthenticationOnPremise { return $true }
@@ -329,10 +329,10 @@ InModuleScope builds {
# Remove any previously loaded accounts
Remove-VSTeamAccount
- $VSTeamVersionTable.Account = 'http://localhost:8080/tfs/defaultcollection'
+ [VSTeamVersions]::Account = 'http://localhost:8080/tfs/defaultcollection'
Context 'Get Build Log with index on TFS local Auth' {
- Mock Invoke-RestMethod { return @{ value = @{} } } -Verifiable -ParameterFilter { $Uri -eq "http://localhost:8080/tfs/defaultcollection/project/_apis/build/builds/1/logs/2?api-version=$($VSTeamVersionTable.Build)" }
+ Mock Invoke-RestMethod { return @{ value = @{} } } -Verifiable -ParameterFilter { $Uri -eq "http://localhost:8080/tfs/defaultcollection/project/_apis/build/builds/1/logs/2?api-version=$([VSTeamVersions]::Build)" }
Mock Invoke-RestMethod { throw 'Invoke-RestMethod called with wrong URL' }
Get-VSTeamBuildLog -projectName project -Id 1 -Index 2
@@ -349,7 +349,7 @@ InModuleScope builds {
Get-VSTeamBuild -projectName project
Assert-MockCalled Invoke-RestMethod -Exactly -Scope It -Times 1 -ParameterFilter {
- $Uri -eq "http://localhost:8080/tfs/defaultcollection/project/_apis/build/builds/?api-version=$($VSTeamVersionTable.Build)"
+ $Uri -eq "http://localhost:8080/tfs/defaultcollection/project/_apis/build/builds/?api-version=$([VSTeamVersions]::Build)"
}
}
}
@@ -360,16 +360,16 @@ InModuleScope builds {
It 'should return builds' {
Get-VSTeamBuild -projectName project -id 2
- Assert-MockCalled Invoke-RestMethod -Exactly -Scope It -Times 1 -ParameterFilter { $Uri -eq "http://localhost:8080/tfs/defaultcollection/project/_apis/build/builds/2?api-version=$($VSTeamVersionTable.Build)" }
+ Assert-MockCalled Invoke-RestMethod -Exactly -Scope It -Times 1 -ParameterFilter { $Uri -eq "http://localhost:8080/tfs/defaultcollection/project/_apis/build/builds/2?api-version=$([VSTeamVersions]::Build)" }
}
}
Context 'Get Build Log on TFS local Auth' {
Mock Invoke-RestMethod { return @{ count = 4 } } -Verifiable -ParameterFilter {
- $Uri -eq "http://localhost:8080/tfs/defaultcollection/project/_apis/build/builds/1/logs/?api-version=$($VSTeamVersionTable.Build)"
+ $Uri -eq "http://localhost:8080/tfs/defaultcollection/project/_apis/build/builds/1/logs/?api-version=$([VSTeamVersions]::Build)"
}
Mock Invoke-RestMethod { return @{ value = @{} } } -Verifiable -ParameterFilter {
- $Uri -eq "http://localhost:8080/tfs/defaultcollection/project/_apis/build/builds/1/logs/3?api-version=$($VSTeamVersionTable.Build)"
+ $Uri -eq "http://localhost:8080/tfs/defaultcollection/project/_apis/build/builds/1/logs/3?api-version=$([VSTeamVersions]::Build)"
}
Mock Invoke-RestMethod { throw 'Invoke-RestMethod called with wrong URL' }
@@ -399,7 +399,7 @@ InModuleScope builds {
It 'should return the build artifact data' {
Assert-MockCalled Invoke-RestMethod -Exactly -Scope Context -Times 1 -ParameterFilter {
- $Uri -eq "http://localhost:8080/tfs/defaultcollection/project/_apis/build/builds/2/artifacts/?api-version=$($VSTeamVersionTable.Build)"
+ $Uri -eq "http://localhost:8080/tfs/defaultcollection/project/_apis/build/builds/2/artifacts/?api-version=$([VSTeamVersions]::Build)"
}
}
}
@@ -428,7 +428,7 @@ InModuleScope builds {
foreach ($inputTag in $inputTags) {
Assert-MockCalled Invoke-RestMethod -Exactly -Scope It -Times 1 -ParameterFilter {
$Method -eq 'Put' -and
- $Uri -eq "http://localhost:8080/tfs/defaultcollection/project/_apis/build/builds/2/tags/?api-version=$($VSTeamVersionTable.Build)" + "&tag=$inputTag"
+ $Uri -eq "http://localhost:8080/tfs/defaultcollection/project/_apis/build/builds/2/tags/?api-version=$([VSTeamVersions]::Build)" + "&tag=$inputTag"
}
}
}
@@ -442,7 +442,7 @@ InModuleScope builds {
Assert-MockCalled Invoke-RestMethod -Exactly -Scope It -Times 1 -ParameterFilter {
$Method -eq 'Delete' -and
- $Uri -eq "http://localhost:8080/tfs/defaultcollection/project/_apis/build/builds/2?api-version=$($VSTeamVersionTable.Build)"
+ $Uri -eq "http://localhost:8080/tfs/defaultcollection/project/_apis/build/builds/2?api-version=$([VSTeamVersions]::Build)"
}
}
}
@@ -466,7 +466,7 @@ InModuleScope builds {
Mock Invoke-RestMethod { return $singleResult } -Verifiable -ParameterFilter {
($Body | ConvertFrom-Json).definition.id -eq 2 -and
($Body | ConvertFrom-Json).queue.id -eq 3 -and
- $Uri -eq "http://localhost:8080/tfs/defaultcollection/project/_apis/build/builds/?api-version=$($VSTeamVersionTable.Build)"
+ $Uri -eq "http://localhost:8080/tfs/defaultcollection/project/_apis/build/builds/?api-version=$([VSTeamVersions]::Build)"
}
Mock Invoke-RestMethod { throw 'Invoke-RestMethod called with wrong URL' }
@@ -497,7 +497,7 @@ InModuleScope builds {
($Body | ConvertFrom-Json).definition.id -eq 2 -and
($Body | ConvertFrom-Json).queue.id -eq 3 -and
(($Body | ConvertFrom-Json).parameters | ConvertFrom-Json).'system.debug' -eq 'true' -and
- $Uri -eq "http://localhost:8080/tfs/defaultcollection/project/_apis/build/builds/?api-version=$($VSTeamVersionTable.Build)"
+ $Uri -eq "http://localhost:8080/tfs/defaultcollection/project/_apis/build/builds/?api-version=$([VSTeamVersions]::Build)"
}
Mock Invoke-RestMethod { throw 'Invoke-RestMethod called with wrong URL' }
@@ -529,7 +529,7 @@ InModuleScope builds {
($Body | ConvertFrom-Json).definition.id -eq 2 -and
($Body | ConvertFrom-Json).queue.id -eq 3 -and
($Body | ConvertFrom-Json).sourceBranch -eq 'refs/heads/dev' -and
- $Uri -eq "http://localhost:8080/tfs/defaultcollection/project/_apis/build/builds/?api-version=$($VSTeamVersionTable.Build)"
+ $Uri -eq "http://localhost:8080/tfs/defaultcollection/project/_apis/build/builds/?api-version=$([VSTeamVersions]::Build)"
}
Mock Invoke-RestMethod { throw 'Invoke-RestMethod called with wrong URL' }
@@ -556,7 +556,7 @@ InModuleScope builds {
foreach ($inputTag in $inputTags) {
Assert-MockCalled Invoke-RestMethod -Exactly -Scope It -Times 1 -ParameterFilter {
$Method -eq 'Delete' -and
- $Uri -eq "http://localhost:8080/tfs/defaultcollection/project/_apis/build/builds/2/tags/?api-version=$($VSTeamVersionTable.Build)" + "&tag=$inputTag"
+ $Uri -eq "http://localhost:8080/tfs/defaultcollection/project/_apis/build/builds/2/tags/?api-version=$([VSTeamVersions]::Build)" + "&tag=$inputTag"
}
}
}
@@ -586,7 +586,7 @@ InModuleScope builds {
Update-VSTeamBuild -projectName project -id 1 -BuildNumber 'TestNumber' -KeepForever $true -Force
It 'should post changes' {
- Assert-MockCalled Invoke-RestMethod -Exactly -Scope Context -Times 1 -ParameterFilter { $Method -eq 'Patch' -and $Body -eq '{"keepForever": true, "buildNumber": "TestNumber"}' -and $Uri -eq "http://localhost:8080/tfs/defaultcollection/project/_apis/build/builds/1?api-version=$($VSTeamVersionTable.Build)" }
+ Assert-MockCalled Invoke-RestMethod -Exactly -Scope Context -Times 1 -ParameterFilter { $Method -eq 'Patch' -and $Body -eq '{"keepForever": true, "buildNumber": "TestNumber"}' -and $Uri -eq "http://localhost:8080/tfs/defaultcollection/project/_apis/build/builds/1?api-version=$([VSTeamVersions]::Build)" }
}
}
}
diff --git a/unit/test/cloudSubscriptions.Tests.ps1 b/unit/test/cloudSubscriptions.Tests.ps1
index cb0bb0959..4a3d40894 100644
--- a/unit/test/cloudSubscriptions.Tests.ps1
+++ b/unit/test/cloudSubscriptions.Tests.ps1
@@ -8,7 +8,7 @@ InModuleScope cloudSubscriptions {
$Uri -like "*_apis/projects*"
}
- $VSTeamVersionTable.Account = 'https://test.visualstudio.com'
+ [VSTeamVersions]::Account = 'https://test.visualstudio.com'
Context 'Get-VSTeamCloudSubscription' {
Mock Invoke-RestMethod {
@@ -19,7 +19,7 @@ InModuleScope cloudSubscriptions {
Get-VSTeamCloudSubscription
Assert-MockCalled Invoke-RestMethod -Exactly -Scope It -Times 1 -ParameterFilter {
- $Uri -eq "https://test.visualstudio.com/_apis/distributedtask/serviceendpointproxy/azurermsubscriptions/?api-version=$($VSTeamVersionTable.DistributedTask)"
+ $Uri -eq "https://test.visualstudio.com/_apis/distributedtask/serviceendpointproxy/azurermsubscriptions/?api-version=$([VSTeamVersions]::DistributedTask)"
}
}
}
@@ -32,7 +32,7 @@ InModuleScope cloudSubscriptions {
}
Mock _useWindowsAuthenticationOnPremise { return $true }
- $VSTeamVersionTable.Account = 'http://localhost:8080/tfs/defaultcollection'
+ [VSTeamVersions]::Account = 'http://localhost:8080/tfs/defaultcollection'
Context 'Get-VSTeamCloudSubscription' {
Mock Invoke-RestMethod { return @{value = 'subs'}}
@@ -41,16 +41,16 @@ InModuleScope cloudSubscriptions {
Get-VSTeamCloudSubscription
Assert-MockCalled Invoke-RestMethod -Exactly -Scope It -Times 1 -ParameterFilter {
- $Uri -eq "http://localhost:8080/tfs/defaultcollection/_apis/distributedtask/serviceendpointproxy/azurermsubscriptions/?api-version=$($VSTeamVersionTable.DistributedTask)"
+ $Uri -eq "http://localhost:8080/tfs/defaultcollection/_apis/distributedtask/serviceendpointproxy/azurermsubscriptions/?api-version=$([VSTeamVersions]::DistributedTask)"
}
}
}
- # Must be last because it sets $VSTeamVersionTable.Account to $null
+ # Must be last because it sets [VSTeamVersions]::Account to $null
Context '_buildURL handles exception' {
# Arrange
- $VSTeamVersionTable.Account = $null
+ [VSTeamVersions]::Account = $null
It 'should return approvals' {
diff --git a/unit/test/common.Tests.ps1 b/unit/test/common.Tests.ps1
index 73332907d..2033513f7 100644
--- a/unit/test/common.Tests.ps1
+++ b/unit/test/common.Tests.ps1
@@ -30,7 +30,7 @@ Describe 'Common' {
Context '_getUserAgent on Mac' {
Mock Get-OperatingSystem { return 'macOS' }
- $VSTeamVersionTable.ModuleVersion = '0.0.0'
+ [VSTeamVersions]::ModuleVersion = '0.0.0'
$actual = _getUserAgent
@@ -49,7 +49,7 @@ Describe 'Common' {
Context '_getUserAgent on Linux' {
Mock Get-OperatingSystem { return 'Linux' }
- $VSTeamVersionTable.ModuleVersion = '0.0.0'
+ [VSTeamVersions]::ModuleVersion = '0.0.0'
$actual = _getUserAgent
@@ -75,7 +75,7 @@ Describe 'Common' {
}
Context '_getWorkItemTypes' {
- $VSTeamVersionTable.Account = $null
+ [VSTeamVersions]::Account = $null
It 'should return empty array' {
_getWorkItemTypes -ProjectName test | Should be @()
diff --git a/unit/test/debug.ps1 b/unit/test/debug.ps1
deleted file mode 100644
index 3f36bbe04..000000000
--- a/unit/test/debug.ps1
+++ /dev/null
@@ -1,4 +0,0 @@
-Import-Module ..\team.psd1 -Force -Verbose
-Add-VSTeamAccount -Account http://10.0.0.5:8080/tfs/DefaultCollection -PersonalAccessToken vuhtbaixci3me7dag364fgp2hccdgzh6zznrvhvfgjzkxrrtmwpa -Verbose
-Set-VSTeamDefaultProject nodeDemo -Verbose
-Remove-VSTeamRelease -id 1 -Verbose -Force
\ No newline at end of file
diff --git a/unit/test/mockProjectDynamicParam.ps1 b/unit/test/mocks/mockProjectDynamicParam.ps1
similarity index 100%
rename from unit/test/mockProjectDynamicParam.ps1
rename to unit/test/mocks/mockProjectDynamicParam.ps1
diff --git a/unit/test/mockProjectDynamicParamMandatoryFalse.ps1 b/unit/test/mocks/mockProjectDynamicParamMandatoryFalse.ps1
similarity index 100%
rename from unit/test/mockProjectDynamicParamMandatoryFalse.ps1
rename to unit/test/mocks/mockProjectDynamicParamMandatoryFalse.ps1
diff --git a/unit/test/mockProjectNameDynamicParam.ps1 b/unit/test/mocks/mockProjectNameDynamicParam.ps1
similarity index 100%
rename from unit/test/mockProjectNameDynamicParam.ps1
rename to unit/test/mocks/mockProjectNameDynamicParam.ps1
diff --git a/unit/test/mockProjectNameDynamicParamNoPSet.ps1 b/unit/test/mocks/mockProjectNameDynamicParamNoPSet.ps1
similarity index 100%
rename from unit/test/mockProjectNameDynamicParamNoPSet.ps1
rename to unit/test/mocks/mockProjectNameDynamicParamNoPSet.ps1
diff --git a/unit/test/policies.Tests.ps1 b/unit/test/policies.Tests.ps1
index 2bf63214d..fb65a9bd7 100644
--- a/unit/test/policies.Tests.ps1
+++ b/unit/test/policies.Tests.ps1
@@ -4,7 +4,7 @@ InModuleScope policies {
# Set the account to use for testing. A normal user would do this
# using the Add-VSTeamAccount function.
- $VSTeamVersionTable.Account = 'https://test.visualstudio.com'
+ [VSTeamVersions]::Account = 'https://test.visualstudio.com'
$results = [PSCustomObject]@{
value = [PSCustomObject]@{ }
@@ -24,7 +24,7 @@ InModuleScope policies {
It 'Should return policies' {
Assert-MockCalled Invoke-RestMethod -Exactly 1 -ParameterFilter {
- $Uri -eq "https://test.visualstudio.com/Demo/_apis/policy/configurations/?api-version=$($VSTeamVersionTable.Core)"
+ $Uri -eq "https://test.visualstudio.com/Demo/_apis/policy/configurations/?api-version=$([VSTeamVersions]::Core)"
}
}
}
@@ -36,7 +36,7 @@ InModuleScope policies {
It 'Should return the policy' {
Assert-MockCalled Invoke-RestMethod -Exactly 1 -ParameterFilter {
- $Uri -eq "https://test.visualstudio.com/Demo/_apis/policy/configurations/4?api-version=$($VSTeamVersionTable.Core)"
+ $Uri -eq "https://test.visualstudio.com/Demo/_apis/policy/configurations/4?api-version=$([VSTeamVersions]::Core)"
}
}
}
@@ -65,7 +65,7 @@ InModuleScope policies {
It 'Should delete the policy' {
Assert-MockCalled Invoke-RestMethod -ParameterFilter {
$Method -eq 'Delete' -and
- $Uri -eq "https://test.visualstudio.com/Demo/_apis/policy/configurations/4?api-version=$($VSTeamVersionTable.Core)"
+ $Uri -eq "https://test.visualstudio.com/Demo/_apis/policy/configurations/4?api-version=$([VSTeamVersions]::Core)"
}
}
}
@@ -103,7 +103,7 @@ InModuleScope policies {
# '{"isBlocking":true,"isEnabled":true,"type":{"id":"babcf51f-d853-43a2-9b05-4a64ca577be0"},"settings":{"scope":[{"repositoryId":"10000000-0000-0000-0000-0000000000001","matchKind":"Exact","refName":"refs/heads/master"}],"MinimumApproverCount":1}}'
Assert-MockCalled Invoke-RestMethod -Times 1 -ParameterFilter {
$Method -eq 'Post' -and
- $Uri -eq "https://test.visualstudio.com/Demo/_apis/policy/configurations/?api-version=$($VSTeamVersionTable.Core)" -and
+ $Uri -eq "https://test.visualstudio.com/Demo/_apis/policy/configurations/?api-version=$([VSTeamVersions]::Core)" -and
$Body -like '*"isBlocking":true*' -and
$Body -like '*"isEnabled":true*' -and
$Body -like '*"type":{"id":"babcf51f-d853-43a2-9b05-4a64ca577be0"}*' -and
@@ -156,7 +156,7 @@ InModuleScope policies {
#'{"isBlocking":true,"isEnabled":true,"type":{"id":"babcf51f-d853-43a2-9b05-4a64ca577be0"},"settings":{"scope":[{"repositoryId":"20000000-0000-0000-0000-0000000000002","matchKind":"Exact","refName":"refs/heads/release"}],"MinimumApproverCount":1}}'
Assert-MockCalled Invoke-RestMethod -Times 1 -ParameterFilter {
$Method -eq 'Put' -and
- $Uri -eq "https://test.visualstudio.com/Demo/_apis/policy/configurations/1?api-version=$($VSTeamVersionTable.Core)" -and
+ $Uri -eq "https://test.visualstudio.com/Demo/_apis/policy/configurations/1?api-version=$([VSTeamVersions]::Core)" -and
$Body -like '*"isBlocking":true*' -and
$Body -like '*"isEnabled":true*' -and
$Body -like '*"type":*' -and
@@ -200,7 +200,7 @@ InModuleScope policies {
#'{"isBlocking":true,"isEnabled":true,"type":{"id":"babcf51f-d853-43a2-9b05-4a64ca577be0"},"settings":{"scope":[{"repositoryId":"20000000-0000-0000-0000-0000000000002","matchKind":"Exact","refName":"refs/heads/release"}],"MinimumApproverCount":1}}'
Assert-MockCalled Invoke-RestMethod -Times 1 -ParameterFilter {
$Method -eq 'Put' -and
- $Uri -eq "https://test.visualstudio.com/Demo/_apis/policy/configurations/1?api-version=$($VSTeamVersionTable.Core)" -and
+ $Uri -eq "https://test.visualstudio.com/Demo/_apis/policy/configurations/1?api-version=$([VSTeamVersions]::Core)" -and
$Body -like '*"isBlocking":true*' -and
$Body -like '*"isEnabled":true*' -and
$Body -like '*"type":*' -and
diff --git a/unit/test/policyTypes.Tests.ps1 b/unit/test/policyTypes.Tests.ps1
index 21d1718dc..f9c4bab2f 100644
--- a/unit/test/policyTypes.Tests.ps1
+++ b/unit/test/policyTypes.Tests.ps1
@@ -4,7 +4,7 @@ InModuleScope policyTypes {
# Set the account to use for testing. A normal user would do this
# using the Add-VSTeamAccount function.
- $VSTeamVersionTable.Account = 'https://test.visualstudio.com'
+ [VSTeamVersions]::Account = 'https://test.visualstudio.com'
$results = [PSCustomObject]@{
value = [PSCustomObject]@{ }
@@ -26,7 +26,7 @@ InModuleScope policyTypes {
It 'Should return policies' {
Assert-MockCalled Invoke-RestMethod -Exactly 1 -ParameterFilter {
- $Uri -eq "https://test.visualstudio.com/Demo/_apis/policy/types/?api-version=$($VSTeamVersionTable.Core)"
+ $Uri -eq "https://test.visualstudio.com/Demo/_apis/policy/types/?api-version=$([VSTeamVersions]::Core)"
}
}
}
@@ -46,7 +46,7 @@ InModuleScope policyTypes {
It 'Should return policies' {
Assert-MockCalled Invoke-RestMethod -Exactly 1 -ParameterFilter {
- $Uri -eq "https://test.visualstudio.com/Demo/_apis/policy/types/90a51335-0c53-4a5f-b6ce-d9aff3ea60e0?api-version=$($VSTeamVersionTable.Core)"
+ $Uri -eq "https://test.visualstudio.com/Demo/_apis/policy/types/90a51335-0c53-4a5f-b6ce-d9aff3ea60e0?api-version=$([VSTeamVersions]::Core)"
}
}
}
diff --git a/unit/test/pools.Tests.ps1 b/unit/test/pools.Tests.ps1
index 7fc909164..3ff009754 100644
--- a/unit/test/pools.Tests.ps1
+++ b/unit/test/pools.Tests.ps1
@@ -1,8 +1,8 @@
Set-StrictMode -Version Latest
InModuleScope pools {
- $VSTeamVersionTable.Account = 'https://test.visualstudio.com'
- $VSTeamVersionTable.DistributedTask = '1.0-unitTest'
+ [VSTeamVersions]::Account = 'https://test.visualstudio.com'
+ [VSTeamVersions]::DistributedTask = '1.0-unitTest'
$hostedPool = [PSCustomObject]@{
owner = [PSCustomObject]@{
@@ -55,7 +55,7 @@ InModuleScope pools {
Get-VSTeamPool
Assert-MockCalled Invoke-RestMethod -Exactly -Scope It -Times 1 -ParameterFilter {
- $Uri -eq "https://test.visualstudio.com/_apis/distributedtask/pools/?api-version=$($VSTeamVersionTable.DistributedTask)"
+ $Uri -eq "https://test.visualstudio.com/_apis/distributedtask/pools/?api-version=$([VSTeamVersions]::DistributedTask)"
}
}
}
@@ -67,7 +67,7 @@ InModuleScope pools {
Get-VSTeamPool -id '1'
Assert-MockCalled Invoke-RestMethod -Exactly -Scope It -Times 1 -ParameterFilter {
- $Uri -eq "https://test.visualstudio.com/_apis/distributedtask/pools/1?api-version=$($VSTeamVersionTable.DistributedTask)"
+ $Uri -eq "https://test.visualstudio.com/_apis/distributedtask/pools/1?api-version=$([VSTeamVersions]::DistributedTask)"
}
}
}
diff --git a/unit/test/projects.Tests.ps1 b/unit/test/projects.Tests.ps1
index b2df41787..9c5b5b64d 100644
--- a/unit/test/projects.Tests.ps1
+++ b/unit/test/projects.Tests.ps1
@@ -1,10 +1,10 @@
Set-StrictMode -Version Latest
InModuleScope projects {
- $VSTeamVersionTable.Account = 'https://test.visualstudio.com'
+ [VSTeamVersions]::Account = 'https://test.visualstudio.com'
Describe 'Project' {
- . "$PSScriptRoot\mockProjectNameDynamicParam.ps1"
+ . "$PSScriptRoot\mocks\mockProjectNameDynamicParam.ps1"
Context 'Show-VSTeamProject by ID' {
Mock Show-Browser
@@ -79,7 +79,7 @@ InModuleScope projects {
# Make sure it was called with the correct URI
Assert-MockCalled Invoke-RestMethod -Exactly 1 -ParameterFilter {
$Uri -like "*https://test.visualstudio.com/_apis/projects/*" -and
- $Uri -like "*api-version=$($VSTeamVersionTable.Core)*" -and
+ $Uri -like "*api-version=$([VSTeamVersions]::Core)*" -and
$Uri -like "*`$top=100*" -and
$Uri -like "*stateFilter=WellFormed*"
}
@@ -112,7 +112,7 @@ InModuleScope projects {
# Make sure it was called with the correct URI
Assert-MockCalled Invoke-RestMethod -Exactly 1 -ParameterFilter {
$Uri -like "*https://test.visualstudio.com/_apis/projects/*" -and
- $Uri -like "*api-version=$($VSTeamVersionTable.Core)*" -and
+ $Uri -like "*api-version=$([VSTeamVersions]::Core)*" -and
$Uri -like "*`$skip=1*" -and
$Uri -like "*`$top=100*" -and
$Uri -like "*stateFilter=WellFormed*"
@@ -130,7 +130,7 @@ InModuleScope projects {
# Make sure it was called with the correct URI
Assert-MockCalled Invoke-RestMethod -Exactly 1 -ParameterFilter {
$Uri -like "*https://test.visualstudio.com/_apis/projects/*" -and
- $Uri -like "*api-version=$($VSTeamVersionTable.Core)*" -and
+ $Uri -like "*api-version=$([VSTeamVersions]::Core)*" -and
$Uri -like "*`$top=100*" -and
$Uri -like "*stateFilter=All*"
}
@@ -146,7 +146,7 @@ InModuleScope projects {
# Make sure it was called with the correct URI
Assert-MockCalled Invoke-RestMethod -Exactly 1 -ParameterFilter {
- $Uri -eq "https://test.visualstudio.com/_apis/projects/Test?api-version=$($VSTeamVersionTable.Core)"
+ $Uri -eq "https://test.visualstudio.com/_apis/projects/Test?api-version=$([VSTeamVersions]::Core)"
}
}
}
@@ -161,7 +161,7 @@ InModuleScope projects {
# Make sure it was called with the correct URI
Assert-MockCalled Invoke-RestMethod -Exactly 1 -ParameterFilter {
$Uri -like "*https://test.visualstudio.com/_apis/projects/Test*" -and
- $Uri -like "*api-version=$($VSTeamVersionTable.Core)*" -and
+ $Uri -like "*api-version=$([VSTeamVersions]::Core)*" -and
$Uri -like "*includeCapabilities=True*"
}
}
@@ -188,47 +188,47 @@ InModuleScope projects {
Context 'Update-VSTeamProject with newName' {
- Mock Invoke-RestMethod { return $singleResult } -ParameterFilter { $Uri -eq "https://test.visualstudio.com/_apis/projects/Test?api-version=$($VSTeamVersionTable.Core)" }
+ Mock Invoke-RestMethod { return $singleResult } -ParameterFilter { $Uri -eq "https://test.visualstudio.com/_apis/projects/Test?api-version=$([VSTeamVersions]::Core)" }
Mock Invoke-RestMethod { return @{status = 'inProgress'; url = 'https://someplace.com'} } -ParameterFilter { $Method -eq 'Patch'}
Mock _trackProjectProgress
- Mock Invoke-RestMethod { return $singleResult } -ParameterFilter { $Uri -eq "https://test.visualstudio.com/_apis/projects/Testing123?api-version=$($VSTeamVersionTable.Core)" }
+ Mock Invoke-RestMethod { return $singleResult } -ParameterFilter { $Uri -eq "https://test.visualstudio.com/_apis/projects/Testing123?api-version=$([VSTeamVersions]::Core)" }
It 'Should change name' {
Update-VSTeamProject -ProjectName Test -newName Testing123 -Force
- Assert-MockCalled Invoke-RestMethod -Times 1 -ParameterFilter { $Uri -eq "https://test.visualstudio.com/_apis/projects/Test?api-version=$($VSTeamVersionTable.Core)" }
+ Assert-MockCalled Invoke-RestMethod -Times 1 -ParameterFilter { $Uri -eq "https://test.visualstudio.com/_apis/projects/Test?api-version=$([VSTeamVersions]::Core)" }
Assert-MockCalled Invoke-RestMethod -Times 1 -ParameterFilter { $Method -eq 'Patch' -and $Body -eq '{"name": "Testing123"}'}
- Assert-MockCalled Invoke-RestMethod -Times 1 -ParameterFilter { $Uri -eq "https://test.visualstudio.com/_apis/projects/Testing123?api-version=$($VSTeamVersionTable.Core)" }
+ Assert-MockCalled Invoke-RestMethod -Times 1 -ParameterFilter { $Uri -eq "https://test.visualstudio.com/_apis/projects/Testing123?api-version=$([VSTeamVersions]::Core)" }
}
}
Context 'Update-VSTeamProject with newDescription' {
- Mock Invoke-RestMethod { return $singleResult } -ParameterFilter { $Uri -eq "https://test.visualstudio.com/_apis/projects/Test?api-version=$($VSTeamVersionTable.Core)" }
+ Mock Invoke-RestMethod { return $singleResult } -ParameterFilter { $Uri -eq "https://test.visualstudio.com/_apis/projects/Test?api-version=$([VSTeamVersions]::Core)" }
Mock Invoke-RestMethod { return @{status = 'inProgress'; url = 'https://someplace.com'} } -ParameterFilter { $Method -eq 'Patch'}
Mock _trackProjectProgress
It 'Should change description' {
Update-VSTeamProject -ProjectName Test -newDescription Testing123 -Force
- Assert-MockCalled Invoke-RestMethod -Times 2 -ParameterFilter { $Uri -eq "https://test.visualstudio.com/_apis/projects/Test?api-version=$($VSTeamVersionTable.Core)" }
+ Assert-MockCalled Invoke-RestMethod -Times 2 -ParameterFilter { $Uri -eq "https://test.visualstudio.com/_apis/projects/Test?api-version=$([VSTeamVersions]::Core)" }
Assert-MockCalled Invoke-RestMethod -Times 1 -ParameterFilter { $Method -eq 'Patch' -and $Body -eq '{"description": "Testing123"}' }
}
}
Context 'Update-VSTeamProject with new name and description' {
- Mock Invoke-RestMethod { return $singleResult } -ParameterFilter { $Uri -eq "https://test.visualstudio.com/_apis/projects/Test?api-version=$($VSTeamVersionTable.Core)" }
+ Mock Invoke-RestMethod { return $singleResult } -ParameterFilter { $Uri -eq "https://test.visualstudio.com/_apis/projects/Test?api-version=$([VSTeamVersions]::Core)" }
Mock Invoke-RestMethod { return @{status = 'inProgress'; url = 'https://someplace.com'} } -ParameterFilter { $Method -eq 'Patch'}
Mock _trackProjectProgress
- Mock Invoke-RestMethod { return $singleResult } -ParameterFilter { $Uri -eq "https://test.visualstudio.com/_apis/projects/Testing123?api-version=$($VSTeamVersionTable.Core)" }
+ Mock Invoke-RestMethod { return $singleResult } -ParameterFilter { $Uri -eq "https://test.visualstudio.com/_apis/projects/Testing123?api-version=$([VSTeamVersions]::Core)" }
It 'Should not call Invoke-RestMethod' {
Update-VSTeamProject -ProjectName Test -newName Testing123 -newDescription Testing123 -Force
- Assert-MockCalled Invoke-RestMethod -Times 1 -ParameterFilter { $Uri -eq "https://test.visualstudio.com/_apis/projects/Test?api-version=$($VSTeamVersionTable.Core)" }
+ Assert-MockCalled Invoke-RestMethod -Times 1 -ParameterFilter { $Uri -eq "https://test.visualstudio.com/_apis/projects/Test?api-version=$([VSTeamVersions]::Core)" }
Assert-MockCalled Invoke-RestMethod -Times 1 -ParameterFilter { $Method -eq 'Patch'}
- Assert-MockCalled Invoke-RestMethod -Times 1 -ParameterFilter { $Uri -eq "https://test.visualstudio.com/_apis/projects/Testing123?api-version=$($VSTeamVersionTable.Core)" }
+ Assert-MockCalled Invoke-RestMethod -Times 1 -ParameterFilter { $Uri -eq "https://test.visualstudio.com/_apis/projects/Testing123?api-version=$([VSTeamVersions]::Core)" }
}
}
@@ -236,14 +236,14 @@ InModuleScope projects {
Mock Write-Progress
Mock _trackProjectProgress
- Mock Invoke-RestMethod { return $singleResult } -ParameterFilter { $Uri -eq "https://test.visualstudio.com/_apis/projects/Test?api-version=$($VSTeamVersionTable.Core)" }
- Mock Invoke-RestMethod { return @{status = 'inProgress'; url = 'https://someplace.com'} } -ParameterFilter { $Method -eq 'Delete' -and $Uri -eq "https://test.visualstudio.com/_apis/projects/123-5464-dee43?api-version=$($VSTeamVersionTable.Core)"}
+ Mock Invoke-RestMethod { return $singleResult } -ParameterFilter { $Uri -eq "https://test.visualstudio.com/_apis/projects/Test?api-version=$([VSTeamVersions]::Core)" }
+ Mock Invoke-RestMethod { return @{status = 'inProgress'; url = 'https://someplace.com'} } -ParameterFilter { $Method -eq 'Delete' -and $Uri -eq "https://test.visualstudio.com/_apis/projects/123-5464-dee43?api-version=$([VSTeamVersions]::Core)"}
It 'Should not call Invoke-RestMethod' {
Remove-VSTeamProject -ProjectName Test -Force
- Assert-MockCalled Invoke-RestMethod -Times 1 -ParameterFilter { $Uri -eq "https://test.visualstudio.com/_apis/projects/Test?api-version=$($VSTeamVersionTable.Core)" }
- Assert-MockCalled Invoke-RestMethod -Times 1 -ParameterFilter { $Method -eq 'Delete' -and $Uri -eq "https://test.visualstudio.com/_apis/projects/123-5464-dee43?api-version=$($VSTeamVersionTable.Core)"}
+ Assert-MockCalled Invoke-RestMethod -Times 1 -ParameterFilter { $Uri -eq "https://test.visualstudio.com/_apis/projects/Test?api-version=$([VSTeamVersions]::Core)" }
+ Assert-MockCalled Invoke-RestMethod -Times 1 -ParameterFilter { $Method -eq 'Delete' -and $Uri -eq "https://test.visualstudio.com/_apis/projects/123-5464-dee43?api-version=$([VSTeamVersions]::Core)"}
}
}
@@ -252,7 +252,7 @@ InModuleScope projects {
# Add Project
Mock Invoke-RestMethod { return @{status = 'inProgress'; id = '123-5464-dee43'; url = 'https://someplace.com'} } -ParameterFilter {
$Method -eq 'Post' -and
- $Uri -eq "https://test.visualstudio.com/_apis/projects/?api-version=$($VSTeamVersionTable.Core)"
+ $Uri -eq "https://test.visualstudio.com/_apis/projects/?api-version=$([VSTeamVersions]::Core)"
}
# Track Progress
@@ -270,18 +270,18 @@ InModuleScope projects {
# Get-VSTeamProject
Mock Invoke-RestMethod { return $singleResult } -ParameterFilter {
- $Uri -eq "https://test.visualstudio.com/_apis/projects/Test?api-version=$($VSTeamVersionTable.Core)"
+ $Uri -eq "https://test.visualstudio.com/_apis/projects/Test?api-version=$([VSTeamVersions]::Core)"
}
It 'Should create project with tfvc' {
Add-VSTeamProject -Name Test -tfvc
Assert-MockCalled Invoke-RestMethod -Times 1 -ParameterFilter {
- $Uri -eq "https://test.visualstudio.com/_apis/projects/Test?api-version=$($VSTeamVersionTable.Core)"
+ $Uri -eq "https://test.visualstudio.com/_apis/projects/Test?api-version=$([VSTeamVersions]::Core)"
}
Assert-MockCalled Invoke-RestMethod -Times 1 -ParameterFilter {
$Method -eq 'Post' -and
- $Uri -eq "https://test.visualstudio.com/_apis/projects/?api-version=$($VSTeamVersionTable.Core)" -and
+ $Uri -eq "https://test.visualstudio.com/_apis/projects/?api-version=$([VSTeamVersions]::Core)" -and
$Body -eq '{"name": "Test", "description": "", "capabilities": {"versioncontrol": { "sourceControlType": "Tfvc"}, "processTemplate":{"templateTypeId": "6b724908-ef14-45cf-84f8-768b5384da45"}}}'
}
}
@@ -289,38 +289,38 @@ InModuleScope projects {
Context 'Add-VSTeamProject with Agile' {
- Mock Invoke-RestMethod { return @{status = 'inProgress'; id = 1; url = 'https://someplace.com'} } -ParameterFilter { $Method -eq 'Post' -and $Uri -eq "https://test.visualstudio.com/_apis/projects/?api-version=$($VSTeamVersionTable.Core)"}
+ Mock Invoke-RestMethod { return @{status = 'inProgress'; id = 1; url = 'https://someplace.com'} } -ParameterFilter { $Method -eq 'Post' -and $Uri -eq "https://test.visualstudio.com/_apis/projects/?api-version=$([VSTeamVersions]::Core)"}
Mock _trackProjectProgress
- Mock Invoke-RestMethod { return $singleResult } -ParameterFilter { $Uri -eq "https://test.visualstudio.com/_apis/projects/Test?api-version=$($VSTeamVersionTable.Core)" }
+ Mock Invoke-RestMethod { return $singleResult } -ParameterFilter { $Uri -eq "https://test.visualstudio.com/_apis/projects/Test?api-version=$([VSTeamVersions]::Core)" }
It 'Should create project with Agile' {
Add-VSTeamProject -ProjectName Test -processTemplate Agile
- Assert-MockCalled Invoke-RestMethod -Times 1 -ParameterFilter { $Uri -eq "https://test.visualstudio.com/_apis/projects/Test?api-version=$($VSTeamVersionTable.Core)" }
- Assert-MockCalled Invoke-RestMethod -Times 1 -ParameterFilter { $Method -eq 'Post' -and $Uri -eq "https://test.visualstudio.com/_apis/projects/?api-version=$($VSTeamVersionTable.Core)"}
+ Assert-MockCalled Invoke-RestMethod -Times 1 -ParameterFilter { $Uri -eq "https://test.visualstudio.com/_apis/projects/Test?api-version=$([VSTeamVersions]::Core)" }
+ Assert-MockCalled Invoke-RestMethod -Times 1 -ParameterFilter { $Method -eq 'Post' -and $Uri -eq "https://test.visualstudio.com/_apis/projects/?api-version=$([VSTeamVersions]::Core)"}
}
}
Context 'Add-VSTeamProject with CMMI' {
- Mock Invoke-RestMethod { return @{status = 'inProgress'; id = 1; url = 'https://someplace.com'} } -ParameterFilter { $Method -eq 'Post' -and $Uri -eq "https://test.visualstudio.com/_apis/projects/?api-version=$($VSTeamVersionTable.Core)"}
+ Mock Invoke-RestMethod { return @{status = 'inProgress'; id = 1; url = 'https://someplace.com'} } -ParameterFilter { $Method -eq 'Post' -and $Uri -eq "https://test.visualstudio.com/_apis/projects/?api-version=$([VSTeamVersions]::Core)"}
Mock _trackProjectProgress
- Mock Invoke-RestMethod { return $singleResult } -ParameterFilter { $Uri -eq "https://test.visualstudio.com/_apis/projects/Test?api-version=$($VSTeamVersionTable.Core)" }
+ Mock Invoke-RestMethod { return $singleResult } -ParameterFilter { $Uri -eq "https://test.visualstudio.com/_apis/projects/Test?api-version=$([VSTeamVersions]::Core)" }
It 'Should create project with CMMI' {
Add-VSTeamProject -ProjectName Test -processTemplate CMMI
- Assert-MockCalled Invoke-RestMethod -Times 1 -ParameterFilter { $Uri -eq "https://test.visualstudio.com/_apis/projects/Test?api-version=$($VSTeamVersionTable.Core)" }
- Assert-MockCalled Invoke-RestMethod -Times 1 -ParameterFilter { $Method -eq 'Post' -and $Uri -eq "https://test.visualstudio.com/_apis/projects/?api-version=$($VSTeamVersionTable.Core)"}
+ Assert-MockCalled Invoke-RestMethod -Times 1 -ParameterFilter { $Uri -eq "https://test.visualstudio.com/_apis/projects/Test?api-version=$([VSTeamVersions]::Core)" }
+ Assert-MockCalled Invoke-RestMethod -Times 1 -ParameterFilter { $Method -eq 'Post' -and $Uri -eq "https://test.visualstudio.com/_apis/projects/?api-version=$([VSTeamVersions]::Core)"}
}
}
Context 'Add-VSTeamProject throws error' {
- Mock Invoke-RestMethod { return @{status = 'inProgress'; id = 1; url = 'https://someplace.com'} } -ParameterFilter { $Method -eq 'Post' -and $Uri -eq "https://test.visualstudio.com/_apis/projects/?api-version=$($VSTeamVersionTable.Core)"}
+ Mock Invoke-RestMethod { return @{status = 'inProgress'; id = 1; url = 'https://someplace.com'} } -ParameterFilter { $Method -eq 'Post' -and $Uri -eq "https://test.visualstudio.com/_apis/projects/?api-version=$([VSTeamVersions]::Core)"}
Mock Write-Error
Mock _trackProjectProgress { throw 'Test error' }
- Mock Invoke-RestMethod { return $singleResult } -ParameterFilter { $Uri -eq "https://test.visualstudio.com/_apis/projects/Test?api-version=$($VSTeamVersionTable.Core)" }
+ Mock Invoke-RestMethod { return $singleResult } -ParameterFilter { $Uri -eq "https://test.visualstudio.com/_apis/projects/Test?api-version=$([VSTeamVersions]::Core)" }
It 'Should throw' { { Add-VSTeamProject -projectName Test -processTemplate CMMI } | Should throw
}
diff --git a/unit/test/queues.Tests.ps1 b/unit/test/queues.Tests.ps1
index 904b6e90f..37e321f77 100644
--- a/unit/test/queues.Tests.ps1
+++ b/unit/test/queues.Tests.ps1
@@ -1,7 +1,7 @@
Set-StrictMode -Version Latest
InModuleScope queues {
- $VSTeamVersionTable.Account = 'https://test.visualstudio.com'
+ [VSTeamVersions]::Account = 'https://test.visualstudio.com'
Describe 'Queues' {
# Mock the call to Get-Projects by the dynamic parameter for ProjectName
@@ -9,7 +9,7 @@ InModuleScope queues {
$Uri -like "*_apis/projects*"
}
- . "$PSScriptRoot\mockProjectNameDynamicParamNoPSet.ps1"
+ . "$PSScriptRoot\mocks\mockProjectNameDynamicParamNoPSet.ps1"
Context 'Get-VSTeamQueue with no parameters' {
Mock Invoke-RestMethod { return @{
@@ -22,7 +22,7 @@ InModuleScope queues {
Get-VSTeamQueue -ProjectName project
Assert-MockCalled Invoke-RestMethod -Exactly -Scope It -Times 1 -ParameterFilter {
- $Uri -eq "https://test.visualstudio.com/project/_apis/distributedtask/queues/?api-version=$($VSTeamVersionTable.DistributedTask)"
+ $Uri -eq "https://test.visualstudio.com/project/_apis/distributedtask/queues/?api-version=$([VSTeamVersions]::DistributedTask)"
}
}
}
@@ -38,7 +38,7 @@ InModuleScope queues {
Get-VSTeamQueue -projectName project -queueName 'Hosted'
Assert-MockCalled Invoke-RestMethod -Exactly -Scope It -Times 1 -ParameterFilter {
- $Uri -eq "https://test.visualstudio.com/project/_apis/distributedtask/queues/?api-version=$($VSTeamVersionTable.DistributedTask)&queueName=Hosted"
+ $Uri -eq "https://test.visualstudio.com/project/_apis/distributedtask/queues/?api-version=$([VSTeamVersions]::DistributedTask)&queueName=Hosted"
}
}
}
@@ -54,7 +54,7 @@ InModuleScope queues {
Get-VSTeamQueue -projectName project -actionFilter 'None'
Assert-MockCalled Invoke-RestMethod -Exactly -Scope It -Times 1 -ParameterFilter {
- $Uri -eq "https://test.visualstudio.com/project/_apis/distributedtask/queues/?api-version=$($VSTeamVersionTable.DistributedTask)&actionFilter=None"
+ $Uri -eq "https://test.visualstudio.com/project/_apis/distributedtask/queues/?api-version=$([VSTeamVersions]::DistributedTask)&actionFilter=None"
}
}
}
@@ -78,11 +78,11 @@ InModuleScope queues {
# matches I have to search for the portions I expect but can't
# assume the order.
# The general string should look like this:
- # "https://test.visualstudio.com/project/_apis/distributedtask/queues/?api-version=$($VSTeamVersionTable.DistributedTask)&actionFilter=None&queueName=Hosted"
+ # "https://test.visualstudio.com/project/_apis/distributedtask/queues/?api-version=$([VSTeamVersions]::DistributedTask)&actionFilter=None&queueName=Hosted"
Assert-MockCalled Invoke-RestMethod -Exactly -Scope It -Times 1 -ParameterFilter {
$Uri -like "*https://test.visualstudio.com/project/_apis/distributedtask/queues/*" -and
- $Uri -like "*api-version=$($VSTeamVersionTable.DistributedTask)*" -and
+ $Uri -like "*api-version=$([VSTeamVersions]::DistributedTask)*" -and
$Uri -like "*actionFilter=None*" -and
$Uri -like "*queueName=Hosted*"
}
@@ -98,7 +98,7 @@ InModuleScope queues {
Get-VSTeamQueue -projectName project -queueId 3
Assert-MockCalled Invoke-RestMethod -Exactly -Scope It -Times 1 -ParameterFilter {
- $Uri -eq "https://test.visualstudio.com/project/_apis/distributedtask/queues/3?api-version=$($VSTeamVersionTable.DistributedTask)"
+ $Uri -eq "https://test.visualstudio.com/project/_apis/distributedtask/queues/3?api-version=$([VSTeamVersions]::DistributedTask)"
}
}
}
diff --git a/unit/test/refs.Tests.ps1 b/unit/test/refs.Tests.ps1
index de673a8c5..c90ed0e1b 100644
--- a/unit/test/refs.Tests.ps1
+++ b/unit/test/refs.Tests.ps1
@@ -4,7 +4,7 @@ InModuleScope Refs {
# Set the account to use for testing. A normal user would do this
# using the Add-VSTeamAccount function.
- $VSTeamVersionTable.Account = 'https://test.visualstudio.com'
+ [VSTeamVersions]::Account = 'https://test.visualstudio.com'
$results = [PSCustomObject]@{
value = [PSCustomObject]@{
@@ -24,7 +24,7 @@ InModuleScope Refs {
$Uri -like "*_apis/projects*"
}
- . "$PSScriptRoot\mockProjectNameDynamicParam.ps1"
+ . "$PSScriptRoot\mocks\mockProjectNameDynamicParam.ps1"
Context 'Get-VSTeamGitRef' {
Mock Invoke-RestMethod { return $results } -Verifiable
diff --git a/unit/test/release.Tests.ps1 b/unit/test/release.Tests.ps1
index f071ed25c..9673aea1b 100644
--- a/unit/test/release.Tests.ps1
+++ b/unit/test/release.Tests.ps1
@@ -4,8 +4,8 @@ Set-StrictMode -Version Latest
Add-Type -AssemblyName 'System.Web'
InModuleScope releases {
- $VSTeamVersionTable.Account = 'https://test.visualstudio.com'
- $VSTeamVersionTable.Release = '1.0-unittest'
+ [VSTeamVersions]::Account = 'https://test.visualstudio.com'
+ [VSTeamVersions]::Release = '1.0-unittest'
$results = [PSCustomObject]@{
value = [PSCustomObject]@{
@@ -31,7 +31,7 @@ InModuleScope releases {
$Uri -like "*_apis/projects*"
}
- . "$PSScriptRoot\mockProjectNameDynamicParamNoPSet.ps1"
+ . "$PSScriptRoot\mocks\mockProjectNameDynamicParamNoPSet.ps1"
Context 'Show-VSTeamRelease by ID' {
Mock Show-Browser { }
@@ -59,7 +59,7 @@ InModuleScope releases {
Assert-MockCalled Invoke-RestMethod -Exactly -Scope It -Times 1 -ParameterFilter {
$Method -eq 'Delete' -and
- $Uri -eq "https://test.vsrm.visualstudio.com/project/_apis/release/releases/15?api-version=$($VSTeamVersionTable.Release)"
+ $Uri -eq "https://test.vsrm.visualstudio.com/project/_apis/release/releases/15?api-version=$([VSTeamVersions]::Release)"
}
}
}
@@ -82,7 +82,7 @@ InModuleScope releases {
Assert-MockCalled Invoke-RestMethod -Exactly -Scope It -Times 1 -ParameterFilter {
$Method -eq 'Patch' -and
$Body -eq '{ "id": 15, "status": "Abandoned" }' -and
- $Uri -eq "https://test.vsrm.visualstudio.com/project/_apis/release/releases/15?api-version=$($VSTeamVersionTable.Release)"
+ $Uri -eq "https://test.vsrm.visualstudio.com/project/_apis/release/releases/15?api-version=$([VSTeamVersions]::Release)"
}
}
}
@@ -106,7 +106,7 @@ InModuleScope releases {
Get-VSTeamRelease -ProjectName project -Id 15
Assert-MockCalled Invoke-RestMethod -Exactly -Scope It -Times 1 -ParameterFilter {
- $Uri -eq "https://test.vsrm.visualstudio.com/project/_apis/release/releases/15?api-version=$($VSTeamVersionTable.Release)"
+ $Uri -eq "https://test.vsrm.visualstudio.com/project/_apis/release/releases/15?api-version=$([VSTeamVersions]::Release)"
}
}
}
@@ -121,7 +121,7 @@ InModuleScope releases {
Get-VSTeamRelease -projectName project
Assert-MockCalled Invoke-RestMethod -Exactly -Scope It -Times 1 -ParameterFilter {
- $Uri -eq "https://test.vsrm.visualstudio.com/project/_apis/release/releases/?api-version=$($VSTeamVersionTable.Release)"
+ $Uri -eq "https://test.vsrm.visualstudio.com/project/_apis/release/releases/?api-version=$([VSTeamVersions]::Release)"
}
}
}
@@ -136,7 +136,7 @@ InModuleScope releases {
Get-VSTeamRelease -projectName project -expand environments
Assert-MockCalled Invoke-RestMethod -Exactly -Scope It -Times 1 -ParameterFilter {
- $Uri -eq "https://test.vsrm.visualstudio.com/project/_apis/release/releases/?api-version=$($VSTeamVersionTable.Release)&`$expand=environments"
+ $Uri -eq "https://test.vsrm.visualstudio.com/project/_apis/release/releases/?api-version=$([VSTeamVersions]::Release)&`$expand=environments"
}
}
}
@@ -151,7 +151,7 @@ InModuleScope releases {
Get-VSTeamRelease
Assert-MockCalled Invoke-RestMethod -Exactly -Scope It -Times 1 -ParameterFilter {
- $Uri -eq "https://test.vsrm.visualstudio.com/_apis/release/releases/?api-version=$($VSTeamVersionTable.Release)"
+ $Uri -eq "https://test.vsrm.visualstudio.com/_apis/release/releases/?api-version=$([VSTeamVersions]::Release)"
}
}
}
@@ -168,7 +168,7 @@ InModuleScope releases {
Assert-MockCalled Invoke-RestMethod -Exactly -Scope It -Times 1 -ParameterFilter {
$Method -eq 'Patch' -and
$Body -eq $expectedBody -and
- $Uri -eq "https://test.vsrm.visualstudio.com/project/_apis/release/releases/1/environments/15?api-version=$($VSTeamVersionTable.Release)"
+ $Uri -eq "https://test.vsrm.visualstudio.com/project/_apis/release/releases/1/environments/15?api-version=$([VSTeamVersions]::Release)"
}
}
}
@@ -197,7 +197,7 @@ InModuleScope releases {
$Body -like '*"alias": "drop"*' -and
$Body -like '*"id": "2"*' -and
$Body -like '*"sourceBranch": ""*' -and
- $Uri -eq "https://test.vsrm.visualstudio.com/project/_apis/release/releases/?api-version=$($VSTeamVersionTable.Release)"
+ $Uri -eq "https://test.vsrm.visualstudio.com/project/_apis/release/releases/?api-version=$([VSTeamVersions]::Release)"
}
}
}
@@ -279,7 +279,7 @@ InModuleScope releases {
$Body -like '*"alias": "drop"*' -and
$Body -like '*"id": "1"*' -and
$Body -like '*"sourceBranch": ""*' -and
- $Uri -eq "https://test.vsrm.visualstudio.com/project/_apis/release/releases/?api-version=$($VSTeamVersionTable.Release)"
+ $Uri -eq "https://test.vsrm.visualstudio.com/project/_apis/release/releases/?api-version=$([VSTeamVersions]::Release)"
}
}
}
diff --git a/unit/test/releaseDefinitions.Tests.ps1 b/unit/test/releaseDefinitions.Tests.ps1
index 94ac6d417..77704a5de 100644
--- a/unit/test/releaseDefinitions.Tests.ps1
+++ b/unit/test/releaseDefinitions.Tests.ps1
@@ -4,8 +4,8 @@ Set-StrictMode -Version Latest
Add-Type -AssemblyName 'System.Web'
InModuleScope releaseDefinitions {
- $VSTeamVersionTable.Account = 'https://test.visualstudio.com'
- $VSTeamVersionTable.Release = '1.0-unittest'
+ [VSTeamVersions]::Account = 'https://test.visualstudio.com'
+ [VSTeamVersions]::Release = '1.0-unittest'
$results = [PSCustomObject]@{
value = [PSCustomObject]@{
@@ -28,7 +28,7 @@ InModuleScope releaseDefinitions {
$Uri -like "*_apis/projects*"
}
- . "$PSScriptRoot\mockProjectNameDynamicParamNoPSet.ps1"
+ . "$PSScriptRoot\mocks\mockProjectNameDynamicParamNoPSet.ps1"
Context 'Show-VSTeamReleaseDefinition by ID' {
Mock Show-Browser { }
@@ -52,7 +52,7 @@ InModuleScope releaseDefinitions {
Get-VSTeamReleaseDefinition -projectName project
Assert-MockCalled Invoke-RestMethod -Exactly -Scope It -Times 1 -ParameterFilter {
- $Uri -eq "https://test.vsrm.visualstudio.com/project/_apis/release/definitions/?api-version=$($VSTeamVersionTable.Release)"
+ $Uri -eq "https://test.vsrm.visualstudio.com/project/_apis/release/definitions/?api-version=$([VSTeamVersions]::Release)"
}
}
}
@@ -67,7 +67,7 @@ InModuleScope releaseDefinitions {
Get-VSTeamReleaseDefinition -projectName project -expand environments
Assert-MockCalled Invoke-RestMethod -Exactly -Scope It -Times 1 -ParameterFilter {
- $Uri -eq "https://test.vsrm.visualstudio.com/project/_apis/release/definitions/?api-version=$($VSTeamVersionTable.Release)&`$expand=environments"
+ $Uri -eq "https://test.vsrm.visualstudio.com/project/_apis/release/definitions/?api-version=$([VSTeamVersions]::Release)&`$expand=environments"
}
}
}
@@ -83,7 +83,7 @@ InModuleScope releaseDefinitions {
Assert-MockCalled Invoke-RestMethod -Exactly -Scope It -Times 1 -ParameterFilter {
$Method -eq 'Post' -and
$InFile -eq 'Releasedef.json' -and
- $Uri -eq "https://test.vsrm.visualstudio.com/project/_apis/release/definitions/?api-version=$($VSTeamVersionTable.Release)"
+ $Uri -eq "https://test.vsrm.visualstudio.com/project/_apis/release/definitions/?api-version=$([VSTeamVersions]::Release)"
}
}
}
@@ -107,7 +107,7 @@ InModuleScope releaseDefinitions {
Get-VSTeamReleaseDefinition -projectName project -id 15
Assert-MockCalled Invoke-RestMethod -Exactly -Scope It -Times 1 -ParameterFilter {
- $Uri -eq "https://test.vsrm.visualstudio.com/project/_apis/release/definitions/15?api-version=$($VSTeamVersionTable.Release)"
+ $Uri -eq "https://test.vsrm.visualstudio.com/project/_apis/release/definitions/15?api-version=$([VSTeamVersions]::Release)"
}
}
}
@@ -120,15 +120,15 @@ InModuleScope releaseDefinitions {
Assert-MockCalled Invoke-RestMethod -Exactly -Scope It -Times 1 -ParameterFilter {
$Method -eq 'Delete' -and
- $Uri -eq "https://test.vsrm.visualstudio.com/project/_apis/release/definitions/2?api-version=$($VSTeamVersionTable.Release)"
+ $Uri -eq "https://test.vsrm.visualstudio.com/project/_apis/release/definitions/2?api-version=$([VSTeamVersions]::Release)"
}
}
}
# Make sure these test run last as the need differnt
- # $VSTeamVersionTable.Account values
+ # [VSTeamVersions]::Account values
Context 'Get-VSTeamReleaseDefinition with no account' {
- $VSTeamVersionTable.Account = $null
+ [VSTeamVersions]::Account = $null
It 'should return Release definitions' {
{ Get-VSTeamReleaseDefinition -projectName project } | Should Throw
@@ -138,7 +138,7 @@ InModuleScope releaseDefinitions {
Context 'Add-VSTeamReleaseDefinition on TFS local Auth' {
Mock Invoke-RestMethod { return $results }
Mock _useWindowsAuthenticationOnPremise { return $true }
- $VSTeamVersionTable.Account = 'http://localhost:8080/tfs/defaultcollection'
+ [VSTeamVersions]::Account = 'http://localhost:8080/tfs/defaultcollection'
it 'Should add Release' {
Add-VSTeamReleaseDefinition -projectName project -inFile 'Releasedef.json'
@@ -146,7 +146,7 @@ InModuleScope releaseDefinitions {
Assert-MockCalled Invoke-RestMethod -Exactly -Scope It -Times 1 -ParameterFilter {
$Method -eq 'Post' -and
$InFile -eq 'Releasedef.json' -and
- $Uri -eq "http://localhost:8080/tfs/defaultcollection/project/_apis/release/definitions/?api-version=$($VSTeamVersionTable.Release)"
+ $Uri -eq "http://localhost:8080/tfs/defaultcollection/project/_apis/release/definitions/?api-version=$([VSTeamVersions]::Release)"
}
}
}
@@ -154,14 +154,14 @@ InModuleScope releaseDefinitions {
Context 'Remove-VSTeamReleaseDefinition on TFS local Auth' {
Mock Invoke-RestMethod { return $results }
Mock _useWindowsAuthenticationOnPremise { return $true }
- $VSTeamVersionTable.Account = 'http://localhost:8080/tfs/defaultcollection'
+ [VSTeamVersions]::Account = 'http://localhost:8080/tfs/defaultcollection'
Remove-VSTeamReleaseDefinition -projectName project -id 2 -Force
It 'should delete Release definition' {
Assert-MockCalled Invoke-RestMethod -Exactly -Scope Context -Times 1 -ParameterFilter {
$Method -eq 'Delete' -and
- $Uri -eq "http://localhost:8080/tfs/defaultcollection/project/_apis/release/definitions/2?api-version=$($VSTeamVersionTable.Release)"
+ $Uri -eq "http://localhost:8080/tfs/defaultcollection/project/_apis/release/definitions/2?api-version=$([VSTeamVersions]::Release)"
}
}
}
diff --git a/unit/test/repositories.Tests.ps1 b/unit/test/repositories.Tests.ps1
index b43208781..e299f5d75 100644
--- a/unit/test/repositories.Tests.ps1
+++ b/unit/test/repositories.Tests.ps1
@@ -4,7 +4,7 @@ InModuleScope repositories {
# Set the account to use for testing. A normal user would do this
# using the Add-VSTeamAccount function.
- $VSTeamVersionTable.Account = 'https://test.visualstudio.com'
+ [VSTeamVersions]::Account = 'https://test.visualstudio.com'
$results = [PSCustomObject]@{
value = [PSCustomObject]@{
@@ -52,7 +52,7 @@ InModuleScope repositories {
$Uri -like "*_apis/projects*"
}
- . "$PSScriptRoot\mockProjectNameDynamicParam.ps1"
+ . "$PSScriptRoot\mocks\mockProjectNameDynamicParam.ps1"
Context 'Show-VSTeamGitRepository by project' {
Mock Show-Browser -Verifiable -ParameterFilter { $url -eq 'https://test.visualstudio.com/_git/project' }
@@ -138,7 +138,7 @@ InModuleScope repositories {
It 'Should remove Git repo' {
Assert-MockCalled Invoke-RestMethod -ParameterFilter {
$Method -eq 'Delete' -and
- $Uri -eq "https://test.visualstudio.com/_apis/git/repositories/00000000-0000-0000-0000-000000000000?api-version=$($VSTeamVersionTable.Git)"
+ $Uri -eq "https://test.visualstudio.com/_apis/git/repositories/00000000-0000-0000-0000-000000000000?api-version=$([VSTeamVersions]::Git)"
}
}
}
@@ -160,7 +160,7 @@ InModuleScope repositories {
Mock _useWindowsAuthenticationOnPremise { return $true }
- $VSTeamVersionTable.Account = 'http://localhost:8080/tfs/defaultcollection'
+ [VSTeamVersions]::Account = 'http://localhost:8080/tfs/defaultcollection'
Context 'Get-VSTeamGitRepository no parameters' {
Mock Invoke-RestMethod { return $results } -Verifiable
diff --git a/unit/test/buildDef.json b/unit/test/sampleFiles/buildDef.json
similarity index 100%
rename from unit/test/buildDef.json
rename to unit/test/sampleFiles/buildDef.json
diff --git a/unit/test/sampleFiles/buildDef2017.json b/unit/test/sampleFiles/buildDef2017.json
new file mode 100644
index 000000000..10b9fa79e
Binary files /dev/null and b/unit/test/sampleFiles/buildDef2017.json differ
diff --git a/unit/test/sampleFiles/buildDef2018.json b/unit/test/sampleFiles/buildDef2018.json
new file mode 100644
index 000000000..4ee644e78
Binary files /dev/null and b/unit/test/sampleFiles/buildDef2018.json differ
diff --git a/unit/test/sampleFiles/buildDefvsts.json b/unit/test/sampleFiles/buildDefvsts.json
new file mode 100644
index 000000000..3c760ca67
Binary files /dev/null and b/unit/test/sampleFiles/buildDefvsts.json differ
diff --git a/unit/test/sampleFiles/buildDefyaml.json b/unit/test/sampleFiles/buildDefyaml.json
new file mode 100644
index 000000000..67df4291a
Binary files /dev/null and b/unit/test/sampleFiles/buildDefyaml.json differ
diff --git a/unit/test/serviceEndpointTypeSample.json b/unit/test/sampleFiles/serviceEndpointTypeSample.json
similarity index 100%
rename from unit/test/serviceEndpointTypeSample.json
rename to unit/test/sampleFiles/serviceEndpointTypeSample.json
diff --git a/unit/test/serviceendpoints.Tests.ps1 b/unit/test/serviceendpoints.Tests.ps1
index 79fa906fb..a2f51494b 100644
--- a/unit/test/serviceendpoints.Tests.ps1
+++ b/unit/test/serviceendpoints.Tests.ps1
@@ -1,7 +1,7 @@
Set-StrictMode -Version Latest
InModuleScope serviceendpoints {
- $VSTeamVersionTable.Account = 'https://test.visualstudio.com'
+ [VSTeamVersions]::Account = 'https://test.visualstudio.com'
Describe 'ServiceEndpoints TFS2017 throws' {
# Mock the call to Get-Projects by the dynamic parameter for ProjectName
@@ -32,7 +32,7 @@ InModuleScope serviceendpoints {
$Uri -like "*_apis/projects*"
}
- . "$PSScriptRoot\mockProjectNameDynamicParamNoPSet.ps1"
+ . "$PSScriptRoot\mocks\mockProjectNameDynamicParamNoPSet.ps1"
Context 'Get-VSTeamServiceEndpoint' {
Mock Write-Verbose
@@ -53,7 +53,7 @@ InModuleScope serviceendpoints {
Get-VSTeamServiceEndpoint -projectName project -Verbose
Assert-MockCalled Invoke-RestMethod -Exactly -Scope It -Times 1 -ParameterFilter {
- $Uri -eq "https://test.visualstudio.com/project/_apis/distributedtask/serviceendpoints/?api-version=$($VSTeamVersionTable.DistributedTask)"
+ $Uri -eq "https://test.visualstudio.com/project/_apis/distributedtask/serviceendpoints/?api-version=$([VSTeamVersions]::DistributedTask)"
}
}
}
@@ -65,7 +65,7 @@ InModuleScope serviceendpoints {
Remove-VSTeamServiceEndpoint -projectName project -id 5 -Force
Assert-MockCalled Invoke-RestMethod -Exactly -Scope It -Times 1 -ParameterFilter {
- $Uri -eq "https://test.visualstudio.com/project/_apis/distributedtask/serviceendpoints/5?api-version=$($VSTeamVersionTable.DistributedTask)" -and
+ $Uri -eq "https://test.visualstudio.com/project/_apis/distributedtask/serviceendpoints/5?api-version=$([VSTeamVersions]::DistributedTask)" -and
$Method -eq 'Delete'
}
}
@@ -231,9 +231,9 @@ InModuleScope serviceendpoints {
}
Describe 'ServiceEndpoints VSTS' {
- . "$PSScriptRoot\mockProjectNameDynamicParamNoPSet.ps1"
+ . "$PSScriptRoot\mocks\mockProjectNameDynamicParamNoPSet.ps1"
- $VSTeamVersionTable.ServiceFabricEndpoint = '4.1-preview'
+ [VSTeamVersions]::ServiceFabricEndpoint = '4.1-preview'
Context 'Add-VSTeamServiceFabricEndpoint' {
Mock Write-Progress
diff --git a/unit/test/serviceendpointsTypes.Tests.ps1 b/unit/test/serviceendpointsTypes.Tests.ps1
index 7ac71962f..020be100f 100644
--- a/unit/test/serviceendpointsTypes.Tests.ps1
+++ b/unit/test/serviceendpointsTypes.Tests.ps1
@@ -1,9 +1,9 @@
Set-StrictMode -Version Latest
InModuleScope serviceendpointTypes {
- $sampleFile = "$PSScriptRoot\serviceEndpointTypeSample.json"
+ $sampleFile = "$PSScriptRoot\sampleFiles\serviceEndpointTypeSample.json"
- $VSTeamVersionTable.Account = 'https://test.visualstudio.com'
+ [VSTeamVersions]::Account = 'https://test.visualstudio.com'
Describe 'serviceendpointTypes' {
# Mock the call to Get-Projects by the dynamic parameter for ProjectName
@@ -20,7 +20,7 @@ InModuleScope serviceendpointTypes {
Get-VSTeamServiceEndpointType
Assert-MockCalled Invoke-RestMethod -Exactly -Scope It -Times 1 -ParameterFilter {
- $Uri -eq "https://test.visualstudio.com/_apis/distributedtask/serviceendpointtypes/?api-version=$($VSTeamVersionTable.DistributedTask)"
+ $Uri -eq "https://test.visualstudio.com/_apis/distributedtask/serviceendpointtypes/?api-version=$([VSTeamVersions]::DistributedTask)"
}
}
}
@@ -34,7 +34,7 @@ InModuleScope serviceendpointTypes {
Get-VSTeamServiceEndpointType -Type azurerm
Assert-MockCalled Invoke-RestMethod -Exactly -Scope It -Times 1 -ParameterFilter {
- $Uri -eq "https://test.visualstudio.com/_apis/distributedtask/serviceendpointtypes/?api-version=$($VSTeamVersionTable.DistributedTask)" -and
+ $Uri -eq "https://test.visualstudio.com/_apis/distributedtask/serviceendpointtypes/?api-version=$([VSTeamVersions]::DistributedTask)" -and
$Body.type -eq 'azurerm'
}
}
@@ -49,7 +49,7 @@ InModuleScope serviceendpointTypes {
Get-VSTeamServiceEndpointType -Type azurerm -Scheme Basic
Assert-MockCalled Invoke-RestMethod -Exactly -Scope It -Times 1 -ParameterFilter {
- $Uri -eq "https://test.visualstudio.com/_apis/distributedtask/serviceendpointtypes/?api-version=$($VSTeamVersionTable.DistributedTask)" -and
+ $Uri -eq "https://test.visualstudio.com/_apis/distributedtask/serviceendpointtypes/?api-version=$([VSTeamVersions]::DistributedTask)" -and
$Body.type -eq 'azurerm' -and
$Body.scheme -eq 'Basic'
}
@@ -65,7 +65,7 @@ InModuleScope serviceendpointTypes {
Get-VSTeamServiceEndpointType -Scheme Basic
Assert-MockCalled Invoke-RestMethod -Exactly -Scope It -Times 1 -ParameterFilter {
- $Uri -eq "https://test.visualstudio.com/_apis/distributedtask/serviceendpointtypes/?api-version=$($VSTeamVersionTable.DistributedTask)" -and
+ $Uri -eq "https://test.visualstudio.com/_apis/distributedtask/serviceendpointtypes/?api-version=$([VSTeamVersions]::DistributedTask)" -and
$Body.scheme -eq 'Basic'
}
}
diff --git a/unit/test/team.Tests.ps1 b/unit/test/team.Tests.ps1
index 5685da2e5..f8f19c5fb 100644
--- a/unit/test/team.Tests.ps1
+++ b/unit/test/team.Tests.ps1
@@ -10,7 +10,7 @@ InModuleScope team {
Mock Write-Host
Context 'Invoke-VSTeamRequest Options' {
- $VSTeamVersionTable.Account = 'https://test.visualstudio.com'
+ [VSTeamVersions]::Account = 'https://test.visualstudio.com'
Mock Invoke-RestMethod { Write-Host $args }
Invoke-VSTeamRequest -Method Options
@@ -21,7 +21,7 @@ InModuleScope team {
}
Context 'Invoke-VSTeamRequest Release' {
- $VSTeamVersionTable.Account = 'https://test.visualstudio.com'
+ [VSTeamVersions]::Account = 'https://test.visualstudio.com'
Mock Invoke-RestMethod { Write-Host $args } -Verifiable
Invoke-VSTeamRequest -Area release -Resource releases -Id 1 -SubDomain vsrm -Version '4.1-preview' -ProjectName testproject -JSON
@@ -38,7 +38,7 @@ InModuleScope team {
$Uri -like "*_apis/projects*"
}
- . "$PSScriptRoot\mockProjectDynamicParamMandatoryFalse.ps1"
+ . "$PSScriptRoot\mocks\mockProjectDynamicParamMandatoryFalse.ps1"
$contents = @"
[
@@ -71,7 +71,7 @@ InModuleScope team {
Context 'Get-VSTeamInfo' {
It 'should return account and default project' {
- $VSTeamVersionTable.Account = "mydemos"
+ [VSTeamVersions]::Account = "mydemos"
$Global:PSDefaultParameterValues['*:projectName'] = 'MyProject'
$info = Get-VSTeamInfo
@@ -107,7 +107,7 @@ InModuleScope team {
Context 'Get-VSTeamOption' {
# Set the account to use for testing. A normal user would do this
# using the Add-VSTeamAccount function.
- $VSTeamVersionTable.Account = 'https://test.visualstudio.com'
+ [VSTeamVersions]::Account = 'https://test.visualstudio.com'
Mock Invoke-RestMethod { return @{
count = 1
@@ -494,22 +494,22 @@ InModuleScope team {
Context 'Set-VSTeamAPIVersion' {
BeforeEach {
- $VSTeamVersionTable.Version = ''
+ [VSTeamVersions]::Version = ''
}
It 'Should default to TFS2017' {
Set-VSTeamAPIVersion
- $VSTeamVersionTable.Version | Should Be 'TFS2017'
+ [VSTeamVersions]::Version | Should Be 'TFS2017'
}
It 'Should return TFS2018' {
Set-VSTeamAPIVersion -Version TFS2018
- $VSTeamVersionTable.Version | Should Be 'TFS2018'
+ [VSTeamVersions]::Version | Should Be 'TFS2018'
}
It 'Should VSTS' {
Set-VSTeamAPIVersion -Version VSTS
- $VSTeamVersionTable.Version | Should Be 'VSTS'
+ [VSTeamVersions]::Version | Should Be 'VSTS'
}
}
}
diff --git a/unit/test/teammembers.Tests.ps1 b/unit/test/teammembers.Tests.ps1
index 25831e801..2ecb18e6d 100644
--- a/unit/test/teammembers.Tests.ps1
+++ b/unit/test/teammembers.Tests.ps1
@@ -1,10 +1,10 @@
Set-StrictMode -Version Latest
InModuleScope teammembers {
- $VSTeamVersionTable.Account = 'https://test.visualstudio.com'
+ [VSTeamVersions]::Account = 'https://test.visualstudio.com'
Describe "TeamMembers" {
- . "$PSScriptRoot\mockProjectNameDynamicParam.ps1"
+ . "$PSScriptRoot\mocks\mockProjectNameDynamicParam.ps1"
Context 'Get-VSTeamMember for specific project and team' {
Mock Invoke-RestMethod { return @{value = 'teams'}}
@@ -13,7 +13,7 @@ InModuleScope teammembers {
Get-VSTeamMember -ProjectName TestProject -TeamId TestTeam
# Make sure it was called with the correct URI
Assert-MockCalled Invoke-RestMethod -Exactly 1 -ParameterFilter {
- $Uri -eq "https://test.visualstudio.com/_apis/projects/TestProject/teams/TestTeam/members?api-version=$($VSTeamVersionTable.Core)"
+ $Uri -eq "https://test.visualstudio.com/_apis/projects/TestProject/teams/TestTeam/members?api-version=$([VSTeamVersions]::Core)"
}
}
}
@@ -26,7 +26,7 @@ InModuleScope teammembers {
# Make sure it was called with the correct URI
Assert-MockCalled Invoke-RestMethod -Exactly 1 -ParameterFilter {
$Uri -like "*https://test.visualstudio.com/_apis/projects/TestProject/teams/TestTeam/members*" -and
- $Uri -like "*api-version=$($VSTeamVersionTable.Core)*" -and
+ $Uri -like "*api-version=$([VSTeamVersions]::Core)*" -and
$Uri -like "*`$top=10*"
}
}
@@ -40,7 +40,7 @@ InModuleScope teammembers {
# Make sure it was called with the correct URI
Assert-MockCalled Invoke-RestMethod -Exactly 1 -ParameterFilter {
$Uri -like "*https://test.visualstudio.com/_apis/projects/TestProject/teams/TestTeam/members*" -and
- $Uri -like "*api-version=$($VSTeamVersionTable.Core)*" -and
+ $Uri -like "*api-version=$([VSTeamVersions]::Core)*" -and
$Uri -like "*`$skip=5*"
}
}
@@ -54,7 +54,7 @@ InModuleScope teammembers {
# Make sure it was called with the correct URI
Assert-MockCalled Invoke-RestMethod -Exactly 1 -ParameterFilter {
$Uri -like "*https://test.visualstudio.com/_apis/projects/TestProject/teams/TestTeam/members*" -and
- $Uri -like "*api-version=$($VSTeamVersionTable.Core)*" -and
+ $Uri -like "*api-version=$([VSTeamVersions]::Core)*" -and
$Uri -like "*`$top=10*" -and
$Uri -like "*`$skip=5*"
}
@@ -68,16 +68,16 @@ InModuleScope teammembers {
New-Object -TypeName PSObject -Prop @{projectname = "TestProject"; name = "TestTeam"} | Get-VSTeamMember
Assert-MockCalled Invoke-RestMethod -Exactly 1 -ParameterFilter {
- $Uri -eq "https://test.visualstudio.com/_apis/projects/TestProject/teams/TestTeam/members?api-version=$($VSTeamVersionTable.Core)"
+ $Uri -eq "https://test.visualstudio.com/_apis/projects/TestProject/teams/TestTeam/members?api-version=$([VSTeamVersions]::Core)"
}
}
}
- # Must be last because it sets $VSTeamVersionTable.Account to $null
+ # Must be last because it sets [VSTeamVersions]::Account to $null
Context '_buildURL handles exception' {
# Arrange
- $VSTeamVersionTable.Account = $null
+ [VSTeamVersions]::Account = $null
It 'should return approvals' {
diff --git a/unit/test/teams.Tests.ps1 b/unit/test/teams.Tests.ps1
index 85ed17659..cef1f65d3 100644
--- a/unit/test/teams.Tests.ps1
+++ b/unit/test/teams.Tests.ps1
@@ -1,7 +1,7 @@
Set-StrictMode -Version Latest
InModuleScope teams {
- $VSTeamVersionTable.Account = 'https://test.visualstudio.com'
+ [VSTeamVersions]::Account = 'https://test.visualstudio.com'
$results = [PSCustomObject]@{
value = [PSCustomObject]@{
@@ -18,7 +18,7 @@ InModuleScope teams {
}
Describe "Teams VSTS" {
- . "$PSScriptRoot\mockProjectNameDynamicParam.ps1"
+ . "$PSScriptRoot\mocks\mockProjectNameDynamicParam.ps1"
Context 'Get-VSTeam with project name' {
Mock Invoke-RestMethod { return $results }
@@ -28,7 +28,7 @@ InModuleScope teams {
# Make sure it was called with the correct URI
Assert-MockCalled Invoke-RestMethod -Exactly 1 -ParameterFilter {
- $Uri -eq "https://test.visualstudio.com/_apis/projects/Test/teams/?api-version=$($VSTeamVersionTable.Core)"
+ $Uri -eq "https://test.visualstudio.com/_apis/projects/Test/teams/?api-version=$([VSTeamVersions]::Core)"
}
}
}
@@ -44,10 +44,10 @@ InModuleScope teams {
# matches I have to search for the portions I expect but can't
# assume the order.
# The general string should look like this:
- # "https://test.visualstudio.com/_apis/projects/Test/teams/?api-version=$($VSTeamVersionTable.Core)&`$top=10"
+ # "https://test.visualstudio.com/_apis/projects/Test/teams/?api-version=$([VSTeamVersions]::Core)&`$top=10"
Assert-MockCalled Invoke-RestMethod -Exactly 1 -ParameterFilter {
$Uri -like "https://test.visualstudio.com/_apis/projects/Test/teams/*" -and
- $Uri -like "*api-version=$($VSTeamVersionTable.Core)*" -and
+ $Uri -like "*api-version=$([VSTeamVersions]::Core)*" -and
$Uri -like "*`$top=10*"
}
}
@@ -62,7 +62,7 @@ InModuleScope teams {
# Make sure it was called with the correct URI
Assert-MockCalled Invoke-RestMethod -Exactly 1 -ParameterFilter {
$Uri -like "*https://test.visualstudio.com/_apis/projects/Test/teams/*" -and
- $Uri -like "*api-version=$($VSTeamVersionTable.Core)*" -and
+ $Uri -like "*api-version=$([VSTeamVersions]::Core)*" -and
$Uri -like "*`$skip=10*"
}
}
@@ -77,7 +77,7 @@ InModuleScope teams {
# Make sure it was called with the correct URI
Assert-MockCalled Invoke-RestMethod -Exactly 1 -ParameterFilter {
$Uri -like "*https://test.visualstudio.com/_apis/projects/Test/teams/*" -and
- $Uri -like "*api-version=$($VSTeamVersionTable.Core)*" -and
+ $Uri -like "*api-version=$([VSTeamVersions]::Core)*" -and
$Uri -like "*`$top=10*" -and
$Uri -like "*`$skip=5*"
}
@@ -92,7 +92,7 @@ InModuleScope teams {
# Make sure it was called with the correct URI
Assert-MockCalled Invoke-RestMethod -Exactly 1 -ParameterFilter {
- $Uri -eq "https://test.visualstudio.com/_apis/projects/Test/teams/TestTeamId?api-version=$($VSTeamVersionTable.Core)"
+ $Uri -eq "https://test.visualstudio.com/_apis/projects/Test/teams/TestTeamId?api-version=$([VSTeamVersions]::Core)"
}
}
}
@@ -105,7 +105,7 @@ InModuleScope teams {
# Make sure it was called with the correct URI
Assert-MockCalled Invoke-RestMethod -Exactly 1 -ParameterFilter {
- $Uri -eq "https://test.visualstudio.com/_apis/projects/Test/teams/TestTeamName?api-version=$($VSTeamVersionTable.Core)"
+ $Uri -eq "https://test.visualstudio.com/_apis/projects/Test/teams/TestTeamName?api-version=$([VSTeamVersions]::Core)"
}
}
}
@@ -119,7 +119,7 @@ InModuleScope teams {
$expectedBody = '{ "name": "TestTeam", "description": "" }'
Assert-MockCalled Invoke-RestMethod -Exactly 1 -ParameterFilter {
- $Uri -eq "https://test.visualstudio.com/_apis/projects/Test/teams/?api-version=$($VSTeamVersionTable.Core)" -and
+ $Uri -eq "https://test.visualstudio.com/_apis/projects/Test/teams/?api-version=$([VSTeamVersions]::Core)" -and
$Method -eq "Post" -and
$Body -eq $expectedBody
}
@@ -135,7 +135,7 @@ InModuleScope teams {
$expectedBody = '{ "name": "TestTeam", "description": "Test Description" }'
Assert-MockCalled Invoke-RestMethod -Exactly 1 -ParameterFilter {
- $Uri -eq "https://test.visualstudio.com/_apis/projects/Test/teams/?api-version=$($VSTeamVersionTable.Core)" -and
+ $Uri -eq "https://test.visualstudio.com/_apis/projects/Test/teams/?api-version=$([VSTeamVersions]::Core)" -and
$Method -eq "Post" -and
$Body -eq $expectedBody
}
@@ -157,7 +157,7 @@ InModuleScope teams {
$expectedBody = '{ "name": "NewTeamName" }'
Assert-MockCalled Invoke-RestMethod -Exactly 1 -ParameterFilter {
- $Uri -eq "https://test.visualstudio.com/_apis/projects/Test/teams/OldTeamName?api-version=$($VSTeamVersionTable.Core)" -and
+ $Uri -eq "https://test.visualstudio.com/_apis/projects/Test/teams/OldTeamName?api-version=$([VSTeamVersions]::Core)" -and
$Method -eq "Patch" -and
$Body -eq $expectedBody
}
@@ -173,7 +173,7 @@ InModuleScope teams {
$expectedBody = '{"description": "New Description" }'
Assert-MockCalled Invoke-RestMethod -Exactly 1 -ParameterFilter {
- $Uri -eq "https://test.visualstudio.com/_apis/projects/Test/teams/OldTeamName?api-version=$($VSTeamVersionTable.Core)" -and
+ $Uri -eq "https://test.visualstudio.com/_apis/projects/Test/teams/OldTeamName?api-version=$([VSTeamVersions]::Core)" -and
$Method -eq "Patch" -and
$Body -eq $expectedBody
}
@@ -189,7 +189,7 @@ InModuleScope teams {
$expectedBody = '{ "name": "NewTeamName", "description": "New Description" }'
Assert-MockCalled Invoke-RestMethod -Exactly 1 -ParameterFilter {
- $Uri -eq "https://test.visualstudio.com/_apis/projects/Test/teams/OldTeamName?api-version=$($VSTeamVersionTable.Core)" -and
+ $Uri -eq "https://test.visualstudio.com/_apis/projects/Test/teams/OldTeamName?api-version=$([VSTeamVersions]::Core)" -and
$Method -eq "Patch" -and
$Body -eq $expectedBody
}
@@ -206,7 +206,7 @@ InModuleScope teams {
$expectedBody = '{ "name": "NewTeamName", "description": "New Description" }'
Assert-MockCalled Invoke-RestMethod -Exactly 1 -ParameterFilter {
- $Uri -eq "https://test.visualstudio.com/_apis/projects/TestProject/teams/OldTeamName?api-version=$($VSTeamVersionTable.Core)" -and
+ $Uri -eq "https://test.visualstudio.com/_apis/projects/TestProject/teams/OldTeamName?api-version=$([VSTeamVersions]::Core)" -and
$Method -eq "Patch" -and
$Body -eq $expectedBody
}
@@ -220,7 +220,7 @@ InModuleScope teams {
Remove-VSTeam -ProjectName Test -TeamId "TestTeam" -Force
Assert-MockCalled Invoke-RestMethod -Exactly 1 -ParameterFilter {
- $Uri -eq "https://test.visualstudio.com/_apis/projects/Test/teams/TestTeam?api-version=$($VSTeamVersionTable.Core)" -and
+ $Uri -eq "https://test.visualstudio.com/_apis/projects/Test/teams/TestTeam?api-version=$([VSTeamVersions]::Core)" -and
$Method -eq "Delete"
}
}
@@ -234,7 +234,7 @@ InModuleScope teams {
Get-VSTeam -ProjectName TestProject -TeamId "TestTeam" | Remove-VSTeam -Force
Assert-MockCalled Invoke-RestMethod -Exactly 1 -ParameterFilter {
- $Uri -eq "https://test.visualstudio.com/_apis/projects/TestProject/teams/TestTeam?api-version=$($VSTeamVersionTable.Core)" -and
+ $Uri -eq "https://test.visualstudio.com/_apis/projects/TestProject/teams/TestTeam?api-version=$([VSTeamVersions]::Core)" -and
$Method -eq "Delete"
}
}
@@ -242,11 +242,11 @@ InModuleScope teams {
}
Describe "Teams TFS" {
- . "$PSScriptRoot\mockProjectNameDynamicParam.ps1"
+ . "$PSScriptRoot\mocks\mockProjectNameDynamicParam.ps1"
Mock _useWindowsAuthenticationOnPremise { return $true }
- $VSTeamVersionTable.Account = 'http://localhost:8080/tfs/defaultcollection'
+ [VSTeamVersions]::Account = 'http://localhost:8080/tfs/defaultcollection'
Context 'Get-VSTeam with project name on TFS local Auth' {
Mock Invoke-RestMethod { return $results }
@@ -256,7 +256,7 @@ InModuleScope teams {
# Make sure it was called with the correct URI
Assert-MockCalled Invoke-RestMethod -Exactly 1 -ParameterFilter {
- $Uri -eq "http://localhost:8080/tfs/defaultcollection/_apis/projects/Test/teams/?api-version=$($VSTeamVersionTable.Core)"
+ $Uri -eq "http://localhost:8080/tfs/defaultcollection/_apis/projects/Test/teams/?api-version=$([VSTeamVersions]::Core)"
}
}
}
@@ -270,7 +270,7 @@ InModuleScope teams {
# Make sure it was called with the correct URI
Assert-MockCalled Invoke-RestMethod -Exactly 1 -ParameterFilter {
$Uri -like "*http://localhost:8080/tfs/defaultcollection/_apis/projects/Test/teams/?*" -and
- $Uri -like "*api-version=$($VSTeamVersionTable.Core)*" -and
+ $Uri -like "*api-version=$([VSTeamVersions]::Core)*" -and
$Uri -like "*`$top=10*"
}
}
@@ -285,7 +285,7 @@ InModuleScope teams {
# Make sure it was called with the correct URI
Assert-MockCalled Invoke-RestMethod -Exactly 1 -ParameterFilter {
$Uri -like "*http://localhost:8080/tfs/defaultcollection/_apis/projects/Test/teams/*" -and
- $Uri -like "*api-version=$($VSTeamVersionTable.Core)*" -and
+ $Uri -like "*api-version=$([VSTeamVersions]::Core)*" -and
$Uri -like "*`$skip=10*"
}
}
@@ -300,7 +300,7 @@ InModuleScope teams {
# Make sure it was called with the correct URI
Assert-MockCalled Invoke-RestMethod -Exactly 1 -ParameterFilter {
$Uri -like "*http://localhost:8080/tfs/defaultcollection/_apis/projects/Test/teams/*" -and
- $Uri -like "*api-version=$($VSTeamVersionTable.Core)*" -and
+ $Uri -like "*api-version=$([VSTeamVersions]::Core)*" -and
$Uri -like "*`$top=10*" -and
$Uri -like "*`$skip=5*"
}
@@ -315,7 +315,7 @@ InModuleScope teams {
# Make sure it was called with the correct URI
Assert-MockCalled Invoke-RestMethod -Exactly 1 -ParameterFilter {
- $Uri -eq "http://localhost:8080/tfs/defaultcollection/_apis/projects/Test/teams/TestTeamName?api-version=$($VSTeamVersionTable.Core)"
+ $Uri -eq "http://localhost:8080/tfs/defaultcollection/_apis/projects/Test/teams/TestTeamName?api-version=$([VSTeamVersions]::Core)"
}
}
}
@@ -328,7 +328,7 @@ InModuleScope teams {
# Make sure it was called with the correct URI
Assert-MockCalled Invoke-RestMethod -Exactly 1 -ParameterFilter {
- $Uri -eq "http://localhost:8080/tfs/defaultcollection/_apis/projects/Test/teams/TestTeamId?api-version=$($VSTeamVersionTable.Core)"
+ $Uri -eq "http://localhost:8080/tfs/defaultcollection/_apis/projects/Test/teams/TestTeamId?api-version=$([VSTeamVersions]::Core)"
}
}
}
@@ -342,7 +342,7 @@ InModuleScope teams {
$expectedBody = '{ "name": "TestTeam", "description": "" }'
Assert-MockCalled Invoke-RestMethod -Exactly 1 -ParameterFilter {
- $Uri -eq "http://localhost:8080/tfs/defaultcollection/_apis/projects/Test/teams/?api-version=$($VSTeamVersionTable.Core)" -and
+ $Uri -eq "http://localhost:8080/tfs/defaultcollection/_apis/projects/Test/teams/?api-version=$([VSTeamVersions]::Core)" -and
$Method -eq "Post" -and
$Body -eq $expectedBody
}
@@ -358,7 +358,7 @@ InModuleScope teams {
$expectedBody = '{ "name": "NewTeamName" }'
Assert-MockCalled Invoke-RestMethod -Exactly 1 -ParameterFilter {
- $Uri -eq "http://localhost:8080/tfs/defaultcollection/_apis/projects/Test/teams/OldTeamName?api-version=$($VSTeamVersionTable.Core)" -and
+ $Uri -eq "http://localhost:8080/tfs/defaultcollection/_apis/projects/Test/teams/OldTeamName?api-version=$([VSTeamVersions]::Core)" -and
$Method -eq "Patch" -and
$Body -eq $expectedBody
}
@@ -372,17 +372,17 @@ InModuleScope teams {
Remove-VSTeam -ProjectName Test -TeamId "TestTeam" -Force
Assert-MockCalled Invoke-RestMethod -Exactly 1 -ParameterFilter {
- $Uri -eq "http://localhost:8080/tfs/defaultcollection/_apis/projects/Test/teams/TestTeam?api-version=$($VSTeamVersionTable.Core)" -and
+ $Uri -eq "http://localhost:8080/tfs/defaultcollection/_apis/projects/Test/teams/TestTeam?api-version=$([VSTeamVersions]::Core)" -and
$Method -eq "Delete"
}
}
}
- # Must be last because it sets $VSTeamVersionTable.Account to $null
+ # Must be last because it sets [VSTeamVersions]::Account to $null
Context '_buildURL handles exception' {
# Arrange
- $VSTeamVersionTable.Account = $null
+ [VSTeamVersions]::Account = $null
It 'should return approvals' {
diff --git a/unit/test/teamspsdrive.Tests.ps1 b/unit/test/teamspsdrive.Tests.ps1
index c8796a38f..fcc779840 100644
--- a/unit/test/teamspsdrive.Tests.ps1
+++ b/unit/test/teamspsdrive.Tests.ps1
@@ -34,6 +34,95 @@ Describe 'VSTeam Classes' {
}
}
+$buildDefResultsVSTS = Get-Content "$PSScriptRoot\sampleFiles\buildDefvsts.json" -Raw | ConvertFrom-Json
+$buildDefResults2017 = Get-Content "$PSScriptRoot\sampleFiles\buildDef2017.json" -Raw | ConvertFrom-Json
+$buildDefResults2018 = Get-Content "$PSScriptRoot\sampleFiles\buildDef2018.json" -Raw | ConvertFrom-Json
+$buildDefResultsyaml = Get-Content "$PSScriptRoot\sampleFiles\buildDefyaml.json" -Raw | ConvertFrom-Json
+
+Describe 'TFS 2017 Build Definition' {
+ # Mock the call to Get-Projects by the dynamic parameter for ProjectName
+ Mock Invoke-RestMethod { return @() } -ParameterFilter {
+ $Uri -like "*_apis/projects*"
+ }
+
+ Context 'Build Definitions' {
+ Mock Get-VSTeamBuildDefinition {
+ return @(
+ [VSTeamBuildDefinition]::new($buildDefResults2017.value[0], 'TestProject')
+ )
+ }
+
+ $buildDefinitions = [VSTeamBuildDefinitions]::new('Build Definitions', 'TestProject')
+
+ It 'Should create Build Defintions' {
+ $buildDefinitions | Should Not be $null
+ }
+
+ $hasSteps = $buildDefinitions.GetChildItem()[0]
+
+ It 'Should have Steps' {
+ $hasSteps | Should Not Be $null
+ }
+
+ $steps = $hasSteps.GetChildItem()
+
+ It 'Should parse steps' {
+ $steps.Length | Should Be 10
+ }
+ }
+}
+
+Describe 'VSTS Build Definition' {
+ # Mock the call to Get-Projects by the dynamic parameter for ProjectName
+ Mock Invoke-RestMethod { return @() } -ParameterFilter {
+ $Uri -like "*_apis/projects*"
+ }
+
+ Context 'Build Definitions' {
+ Mock Get-VSTeamBuildDefinition {
+ return @(
+ [VSTeamBuildDefinition]::new($buildDefResultsVSTS.value[0], 'TestProject'),
+ [VSTeamBuildDefinition]::new($buildDefResultsyaml.value[0], 'TestProject')
+ )
+ }
+
+ $buildDefinitions = [VSTeamBuildDefinitions]::new('Build Definitions', 'TestProject')
+
+ It 'Should create Build Defintions' {
+ $buildDefinitions | Should Not be $null
+ }
+
+ $VSTeamBuildDefinitionWithPhases = $buildDefinitions.GetChildItem()[0]
+
+ It 'Should parse phases' {
+ $VSTeamBuildDefinitionWithPhases.Process.Phases.Length | Should Be 1
+ }
+
+ It 'Should show steps in tostring' {
+ $VSTeamBuildDefinitionWithPhases.Process.ToString() | Should Be 'Number of phases: 1'
+ }
+
+ $process = $VSTeamBuildDefinitionWithPhases.GetChildItem()[0]
+
+ It 'Should return process' {
+ $process | Should Not Be $null
+ }
+
+ $steps = $process.GetChildItem()
+
+ It 'Should parse steps' {
+ $steps.Length | Should Be 9
+ }
+
+ $yamlBuild = $buildDefinitions.GetChildItem()[1]
+ $yamlFile = $yamlBuild.GetChildItem()
+
+ It 'Should have yamlFilename' {
+ $yamlFile | Should Be '.vsts-ci.yml'
+ }
+ }
+}
+
Describe 'TeamsPSDrive' {
# Mock the call to Get-Projects by the dynamic parameter for ProjectName
Mock Invoke-RestMethod { return @() } -ParameterFilter {
@@ -45,7 +134,7 @@ Describe 'TeamsPSDrive' {
name = 'TestProject'
description = ''
url = ''
- id = '123-5464-dee43'
+ id = '123 - 5464-dee43'
state = ''
visibility = ''
revision = 0
@@ -83,14 +172,16 @@ Describe 'TeamsPSDrive' {
It 'Should return builds, releases, repositories and teams' {
$actual | Should Not Be $null
- $actual[0].Name | Should Be 'Builds'
+ $actual[0].Name | Should Be 'Build Definitions'
$actual[0].ProjectName | Should Be 'TestProject'
- $actual[1].Name | Should Be 'Releases'
+ $actual[1].Name | Should Be 'Builds'
$actual[1].ProjectName | Should Be 'TestProject'
- $actual[2].Name | Should Be 'Repositories'
+ $actual[2].Name | Should Be 'Releases'
$actual[2].ProjectName | Should Be 'TestProject'
- $actual[3].Name | Should Be 'Teams'
+ $actual[3].Name | Should Be 'Repositories'
$actual[3].ProjectName | Should Be 'TestProject'
+ $actual[4].Name | Should Be 'Teams'
+ $actual[4].ProjectName | Should Be 'TestProject'
}
}
@@ -195,10 +286,28 @@ Describe 'TeamsPSDrive' {
}
}
+ Context 'Build Definitions' {
+ Mock Get-VSTeamBuildDefinition { return @(
+ [VSTeamBuildDefinition]::new(@{}, 'TestProject'),
+ [VSTeamBuildDefinition]::new(@{}, 'TestProject')
+ )
+ }
+
+ $buildDefinitions = [VSTeamBuildDefinitions]::new('Build Definitions', 'TestProject')
+
+ It 'Should create Build Defintions' {
+ $buildDefinitions | Should Not be $null
+ }
+
+ # $VSTeamBuildDefinitionWithPhases = $buildDefinitions.GetChildItem()[0]
+
+ # $yamlBuild = $buildDefinitions.GetChildItem()[1]
+ }
+
Context 'Releases' {
Mock Get-VSTeamRelease { return [PSCustomObject]@{
id = 1
- name = 'Release-007'
+ name = 'Release - 007'
status = 'active'
createdBy = [PSCustomObject]@{
displayname = 'Test User'
@@ -297,7 +406,7 @@ Describe 'TeamsPSDrive' {
name = 'TestProject'
description = ''
url = ''
- id = '123-5464-dee43'
+ id = '123 - 5464-dee43'
state = ''
visibility = ''
revision = 0
diff --git a/unit/test/tfvc.Tests.ps1 b/unit/test/tfvc.Tests.ps1
index ce38d109f..6fa48e80a 100644
--- a/unit/test/tfvc.Tests.ps1
+++ b/unit/test/tfvc.Tests.ps1
@@ -29,7 +29,7 @@ InModuleScope tfvc {
$Uri -like "*_apis/projects*"
}
- $VSTeamVersionTable.Account = 'https://test.visualstudio.com'
+ [VSTeamVersions]::Account = 'https://test.visualstudio.com'
Context 'Get-VSTeamTfvcRootBranch with no parameters and single result' {
Mock Invoke-RestMethod { return $singleResult } -Verifiable
@@ -42,7 +42,7 @@ InModuleScope tfvc {
It 'should call the REST endpoint with correct parameters' {
Assert-MockCalled Invoke-RestMethod -Scope Context -Exactly -Times 1 -ParameterFilter {
- $Uri -eq "$($VSTeamVersionTable.Account)/_apis/tfvc/branches/?api-version=$($VSTeamVersionTable.Tfvc)"
+ $Uri -eq "$([VSTeamVersions]::Account)/_apis/tfvc/branches/?api-version=$([VSTeamVersions]::Tfvc)"
}
}
}
@@ -60,7 +60,7 @@ InModuleScope tfvc {
It 'should call the REST endpoint with correct parameters' {
Assert-MockCalled Invoke-RestMethod -Scope Context -Exactly -Times 1 -ParameterFilter {
- $Uri -eq "$($VSTeamVersionTable.Account)/_apis/tfvc/branches/?api-version=$($VSTeamVersionTable.Tfvc)"
+ $Uri -eq "$([VSTeamVersions]::Account)/_apis/tfvc/branches/?api-version=$([VSTeamVersions]::Tfvc)"
}
}
}
@@ -72,7 +72,7 @@ InModuleScope tfvc {
It 'should call the REST endpoint with correct parameters' {
Assert-MockCalled Invoke-RestMethod -Scope Context -Exactly -Times 1 -ParameterFilter {
- $Uri -eq "$($VSTeamVersionTable.Account)/_apis/tfvc/branches/?api-version=$($VSTeamVersionTable.Tfvc)&includeChildren=True"
+ $Uri -eq "$([VSTeamVersions]::Account)/_apis/tfvc/branches/?api-version=$([VSTeamVersions]::Tfvc)&includeChildren=True"
}
}
}
@@ -84,7 +84,7 @@ InModuleScope tfvc {
It 'should call the REST endpoint with correct parameters' {
Assert-MockCalled Invoke-RestMethod -Scope Context -Exactly -Times 1 -ParameterFilter {
- $Uri -eq "$($VSTeamVersionTable.Account)/_apis/tfvc/branches/?api-version=$($VSTeamVersionTable.Tfvc)&includeDeleted=True"
+ $Uri -eq "$([VSTeamVersions]::Account)/_apis/tfvc/branches/?api-version=$([VSTeamVersions]::Tfvc)&includeDeleted=True"
}
}
}
@@ -96,7 +96,7 @@ InModuleScope tfvc {
It 'should call the REST endpoint with correct parameters' {
Assert-MockCalled Invoke-RestMethod -Scope Context -Exactly -Times 1 -ParameterFilter {
- $Uri -eq "$($VSTeamVersionTable.Account)/_apis/tfvc/branches/?api-version=$($VSTeamVersionTable.Tfvc)&includeChildren=True&includeDeleted=True"
+ $Uri -eq "$([VSTeamVersions]::Account)/_apis/tfvc/branches/?api-version=$([VSTeamVersions]::Tfvc)&includeChildren=True&includeDeleted=True"
}
}
}
@@ -108,7 +108,7 @@ InModuleScope tfvc {
$Uri -like "*_apis/projects*"
}
- $VSTeamVersionTable.Account = 'http://localhost:8080/tfs/defaultcollection'
+ [VSTeamVersions]::Account = 'http://localhost:8080/tfs/defaultcollection'
Mock _useWindowsAuthenticationOnPremise { return $true }
Context 'Get-VSTeamTfvcRootBranch with no parameters and single result' {
@@ -122,7 +122,7 @@ InModuleScope tfvc {
It 'should call the REST endpoint with correct parameters' {
Assert-MockCalled Invoke-RestMethod -Scope Context -Exactly -Times 1 -ParameterFilter {
- $Uri -eq "$($VSTeamVersionTable.Account)/_apis/tfvc/branches/?api-version=$($VSTeamVersionTable.Tfvc)"
+ $Uri -eq "$([VSTeamVersions]::Account)/_apis/tfvc/branches/?api-version=$([VSTeamVersions]::Tfvc)"
}
}
}
@@ -140,7 +140,7 @@ InModuleScope tfvc {
It 'should call the REST endpoint with correct parameters' {
Assert-MockCalled Invoke-RestMethod -Scope Context -Exactly -Times 1 -ParameterFilter {
- $Uri -eq "$($VSTeamVersionTable.Account)/_apis/tfvc/branches/?api-version=$($VSTeamVersionTable.Tfvc)"
+ $Uri -eq "$([VSTeamVersions]::Account)/_apis/tfvc/branches/?api-version=$([VSTeamVersions]::Tfvc)"
}
}
}
@@ -152,7 +152,7 @@ InModuleScope tfvc {
It 'should call the REST endpoint with correct parameters' {
Assert-MockCalled Invoke-RestMethod -Scope Context -Exactly -Times 1 -ParameterFilter {
- $Uri -eq "$($VSTeamVersionTable.Account)/_apis/tfvc/branches/?api-version=$($VSTeamVersionTable.Tfvc)&includeChildren=True"
+ $Uri -eq "$([VSTeamVersions]::Account)/_apis/tfvc/branches/?api-version=$([VSTeamVersions]::Tfvc)&includeChildren=True"
}
}
}
@@ -164,7 +164,7 @@ InModuleScope tfvc {
It 'should call the REST endpoint with correct parameters' {
Assert-MockCalled Invoke-RestMethod -Scope Context -Exactly -Times 1 -ParameterFilter {
- $Uri -eq "$($VSTeamVersionTable.Account)/_apis/tfvc/branches/?api-version=$($VSTeamVersionTable.Tfvc)&includeDeleted=True"
+ $Uri -eq "$([VSTeamVersions]::Account)/_apis/tfvc/branches/?api-version=$([VSTeamVersions]::Tfvc)&includeDeleted=True"
}
}
}
@@ -176,7 +176,7 @@ InModuleScope tfvc {
It 'should call the REST endpoint with correct parameters' {
Assert-MockCalled Invoke-RestMethod -Scope Context -Exactly -Times 1 -ParameterFilter {
- $Uri -eq "$($VSTeamVersionTable.Account)/_apis/tfvc/branches/?api-version=$($VSTeamVersionTable.Tfvc)&includeChildren=True&includeDeleted=True"
+ $Uri -eq "$([VSTeamVersions]::Account)/_apis/tfvc/branches/?api-version=$([VSTeamVersions]::Tfvc)&includeChildren=True&includeDeleted=True"
}
}
}
@@ -198,12 +198,12 @@ InModuleScope tfvc {
It 'should call the REST endpoint with correct parameters for ' -TestCases $testCases {
param ($a)
- $VSTeamVersionTable.Account = $a
+ [VSTeamVersions]::Account = $a
Get-VSTeamTfvcBranch -Path $/MyProject/Master
Assert-MockCalled Invoke-RestMethod -Scope Context -Exactly -Times 1 -ParameterFilter {
- $Uri -eq "$($VSTeamVersionTable.Account)/_apis/tfvc/branches/$/MyProject/Master?api-version=$($VSTeamVersionTable.Tfvc)"
+ $Uri -eq "$([VSTeamVersions]::Account)/_apis/tfvc/branches/$/MyProject/Master?api-version=$([VSTeamVersions]::Tfvc)"
}
}
}
@@ -214,7 +214,7 @@ InModuleScope tfvc {
$Uri -like "*_apis/projects*"
}
- $VSTeamVersionTable.Account = 'https://test.visualstudio.com'
+ [VSTeamVersions]::Account = 'https://test.visualstudio.com'
Context 'Get-VSTeamTfvcBranch with one path' {
Mock Invoke-RestMethod { return $singleResult } -Verifiable
@@ -223,7 +223,7 @@ InModuleScope tfvc {
It 'should call the REST endpoint with correct parameters' {
Assert-MockCalled Invoke-RestMethod -Scope Context -Exactly -Times 1 -ParameterFilter {
- $Uri -eq "$($VSTeamVersionTable.Account)/_apis/tfvc/branches/$/MyProject/Master?api-version=$($VSTeamVersionTable.Tfvc)"
+ $Uri -eq "$([VSTeamVersions]::Account)/_apis/tfvc/branches/$/MyProject/Master?api-version=$([VSTeamVersions]::Tfvc)"
}
}
}
@@ -235,7 +235,7 @@ InModuleScope tfvc {
It 'should call the REST endpoint with correct parameters' {
Assert-MockCalled Invoke-RestMethod -Scope Context -Exactly -Times 1 -ParameterFilter {
- $Uri -eq "$($VSTeamVersionTable.Account)/_apis/tfvc/branches/$/MyProject/Master?api-version=$($VSTeamVersionTable.Tfvc)"
+ $Uri -eq "$([VSTeamVersions]::Account)/_apis/tfvc/branches/$/MyProject/Master?api-version=$([VSTeamVersions]::Tfvc)"
}
}
}
@@ -247,10 +247,10 @@ InModuleScope tfvc {
It 'should call the REST endpoint with correct parameters' {
Assert-MockCalled Invoke-RestMethod -Scope Context -Exactly -Times 1 -ParameterFilter {
- $Uri -eq "$($VSTeamVersionTable.Account)/_apis/tfvc/branches/$/MyProject/Master?api-version=$($VSTeamVersionTable.Tfvc)"
+ $Uri -eq "$([VSTeamVersions]::Account)/_apis/tfvc/branches/$/MyProject/Master?api-version=$([VSTeamVersions]::Tfvc)"
}
Assert-MockCalled Invoke-RestMethod -Scope Context -Exactly -Times 1 -ParameterFilter {
- $Uri -eq "$($VSTeamVersionTable.Account)/_apis/tfvc/branches/$/MyProject/Feature?api-version=$($VSTeamVersionTable.Tfvc)"
+ $Uri -eq "$([VSTeamVersions]::Account)/_apis/tfvc/branches/$/MyProject/Feature?api-version=$([VSTeamVersions]::Tfvc)"
}
}
}
@@ -262,7 +262,7 @@ InModuleScope tfvc {
It 'should call the REST endpoint with correct parameters' {
Assert-MockCalled Invoke-RestMethod -Scope Context -Exactly -Times 1 -ParameterFilter {
- $Uri -eq "$($VSTeamVersionTable.Account)/_apis/tfvc/branches/$/MyProject/Master?api-version=$($VSTeamVersionTable.Tfvc)&includeChildren=True"
+ $Uri -eq "$([VSTeamVersions]::Account)/_apis/tfvc/branches/$/MyProject/Master?api-version=$([VSTeamVersions]::Tfvc)&includeChildren=True"
}
}
}
@@ -274,7 +274,7 @@ InModuleScope tfvc {
It 'should call the REST endpoint with correct parameters' {
Assert-MockCalled Invoke-RestMethod -Scope Context -Exactly -Times 1 -ParameterFilter {
- $Uri -eq "$($VSTeamVersionTable.Account)/_apis/tfvc/branches/$/MyProject/Master?api-version=$($VSTeamVersionTable.Tfvc)&includeParent=True"
+ $Uri -eq "$([VSTeamVersions]::Account)/_apis/tfvc/branches/$/MyProject/Master?api-version=$([VSTeamVersions]::Tfvc)&includeParent=True"
}
}
}
@@ -286,7 +286,7 @@ InModuleScope tfvc {
It 'should call the REST endpoint with correct parameters' {
Assert-MockCalled Invoke-RestMethod -Scope Context -Exactly -Times 1 -ParameterFilter {
- $Uri -eq "$($VSTeamVersionTable.Account)/_apis/tfvc/branches/$/MyProject/Master?api-version=$($VSTeamVersionTable.Tfvc)&includeDeleted=True"
+ $Uri -eq "$([VSTeamVersions]::Account)/_apis/tfvc/branches/$/MyProject/Master?api-version=$([VSTeamVersions]::Tfvc)&includeDeleted=True"
}
}
}
@@ -298,7 +298,7 @@ InModuleScope tfvc {
It 'should call the REST endpoint with correct parameters' {
Assert-MockCalled Invoke-RestMethod -Scope Context -Exactly -Times 1 -ParameterFilter {
- $Uri -eq "$($VSTeamVersionTable.Account)/_apis/tfvc/branches/$/MyProject/Master?api-version=$($VSTeamVersionTable.Tfvc)&includeChildren=True&includeParent=True&includeDeleted=True"
+ $Uri -eq "$([VSTeamVersions]::Account)/_apis/tfvc/branches/$/MyProject/Master?api-version=$([VSTeamVersions]::Tfvc)&includeChildren=True&includeParent=True&includeDeleted=True"
}
}
}
@@ -310,7 +310,7 @@ InModuleScope tfvc {
$Uri -like "*_apis/projects*"
}
- $VSTeamVersionTable.Account = 'http://localhost:8080/tfs/defaultcollection'
+ [VSTeamVersions]::Account = 'http://localhost:8080/tfs/defaultcollection'
Mock _useWindowsAuthenticationOnPremise { return $true }
Context 'Get-VSTeamTfvcBranch with one path' {
@@ -320,7 +320,7 @@ InModuleScope tfvc {
It 'should call the REST endpoint with correct parameters' {
Assert-MockCalled Invoke-RestMethod -Scope Context -Exactly -Times 1 -ParameterFilter {
- $Uri -eq "$($VSTeamVersionTable.Account)/_apis/tfvc/branches/$/MyProject/Master?api-version=$($VSTeamVersionTable.Tfvc)"
+ $Uri -eq "$([VSTeamVersions]::Account)/_apis/tfvc/branches/$/MyProject/Master?api-version=$([VSTeamVersions]::Tfvc)"
}
}
}
@@ -332,7 +332,7 @@ InModuleScope tfvc {
It 'should call the REST endpoint with correct parameters' {
Assert-MockCalled Invoke-RestMethod -Scope Context -Exactly -Times 1 -ParameterFilter {
- $Uri -eq "$($VSTeamVersionTable.Account)/_apis/tfvc/branches/$/MyProject/Master?api-version=$($VSTeamVersionTable.Tfvc)"
+ $Uri -eq "$([VSTeamVersions]::Account)/_apis/tfvc/branches/$/MyProject/Master?api-version=$([VSTeamVersions]::Tfvc)"
}
}
}
@@ -344,10 +344,10 @@ InModuleScope tfvc {
It 'should call the REST endpoint with correct parameters' {
Assert-MockCalled Invoke-RestMethod -Scope Context -Exactly -Times 1 -ParameterFilter {
- $Uri -eq "$($VSTeamVersionTable.Account)/_apis/tfvc/branches/$/MyProject/Master?api-version=$($VSTeamVersionTable.Tfvc)"
+ $Uri -eq "$([VSTeamVersions]::Account)/_apis/tfvc/branches/$/MyProject/Master?api-version=$([VSTeamVersions]::Tfvc)"
}
Assert-MockCalled Invoke-RestMethod -Scope Context -Exactly -Times 1 -ParameterFilter {
- $Uri -eq "$($VSTeamVersionTable.Account)/_apis/tfvc/branches/$/MyProject/Feature?api-version=$($VSTeamVersionTable.Tfvc)"
+ $Uri -eq "$([VSTeamVersions]::Account)/_apis/tfvc/branches/$/MyProject/Feature?api-version=$([VSTeamVersions]::Tfvc)"
}
}
}
@@ -359,7 +359,7 @@ InModuleScope tfvc {
It 'should call the REST endpoint with correct parameters' {
Assert-MockCalled Invoke-RestMethod -Scope Context -Exactly -Times 1 -ParameterFilter {
- $Uri -eq "$($VSTeamVersionTable.Account)/_apis/tfvc/branches/$/MyProject/Master?api-version=$($VSTeamVersionTable.Tfvc)&includeChildren=True"
+ $Uri -eq "$([VSTeamVersions]::Account)/_apis/tfvc/branches/$/MyProject/Master?api-version=$([VSTeamVersions]::Tfvc)&includeChildren=True"
}
}
}
@@ -371,7 +371,7 @@ InModuleScope tfvc {
It 'should call the REST endpoint with correct parameters' {
Assert-MockCalled Invoke-RestMethod -Scope Context -Exactly -Times 1 -ParameterFilter {
- $Uri -eq "$($VSTeamVersionTable.Account)/_apis/tfvc/branches/$/MyProject/Master?api-version=$($VSTeamVersionTable.Tfvc)&includeParent=True"
+ $Uri -eq "$([VSTeamVersions]::Account)/_apis/tfvc/branches/$/MyProject/Master?api-version=$([VSTeamVersions]::Tfvc)&includeParent=True"
}
}
}
@@ -383,7 +383,7 @@ InModuleScope tfvc {
It 'should call the REST endpoint with correct parameters' {
Assert-MockCalled Invoke-RestMethod -Scope Context -Exactly -Times 1 -ParameterFilter {
- $Uri -eq "$($VSTeamVersionTable.Account)/_apis/tfvc/branches/$/MyProject/Master?api-version=$($VSTeamVersionTable.Tfvc)&includeDeleted=True"
+ $Uri -eq "$([VSTeamVersions]::Account)/_apis/tfvc/branches/$/MyProject/Master?api-version=$([VSTeamVersions]::Tfvc)&includeDeleted=True"
}
}
}
@@ -395,7 +395,7 @@ InModuleScope tfvc {
It 'should call the REST endpoint with correct parameters' {
Assert-MockCalled Invoke-RestMethod -Scope Context -Exactly -Times 1 -ParameterFilter {
- $Uri -eq "$($VSTeamVersionTable.Account)/_apis/tfvc/branches/$/MyProject/Master?api-version=$($VSTeamVersionTable.Tfvc)&includeChildren=True&includeParent=True&includeDeleted=True"
+ $Uri -eq "$([VSTeamVersions]::Account)/_apis/tfvc/branches/$/MyProject/Master?api-version=$([VSTeamVersions]::Tfvc)&includeChildren=True&includeParent=True&includeDeleted=True"
}
}
}
diff --git a/unit/test/users.Tests.ps1 b/unit/test/users.Tests.ps1
index 1151f47ed..fcacd7c6e 100644
--- a/unit/test/users.Tests.ps1
+++ b/unit/test/users.Tests.ps1
@@ -1,7 +1,7 @@
Set-StrictMode -Version Latest
InModuleScope users {
- $VSTeamVersionTable.Account = 'https://test.visualstudio.com'
+ [VSTeamVersions]::Account = 'https://test.visualstudio.com'
Describe "Users TFS Errors" {
# Mock the call to Get-Projects by the dynamic parameter for ProjectName
@@ -30,10 +30,10 @@ InModuleScope users {
$Uri -like "*_apis/projects*"
}
- . "$PSScriptRoot\mockProjectDynamicParamMandatoryFalse.ps1"
+ . "$PSScriptRoot\mocks\mockProjectDynamicParamMandatoryFalse.ps1"
# Must be defined or call will throw error
- $VSTeamVersionTable.MemberEntitlementManagement = '4.1-preview'
+ [VSTeamVersions]::MemberEntitlementManagement = '4.1-preview'
Context 'Get-VSTeamUser no parameters' {
Mock _callAPI { return [PSCustomObject]@{
@@ -47,7 +47,7 @@ InModuleScope users {
# Make sure it was called with the correct URI
Assert-MockCalled _callAPI -Exactly 1 -ParameterFilter {
- $url -eq "https://test.vsaex.visualstudio.com/_apis/userentitlements/?api-version=$($VSTeamVersionTable.MemberEntitlementManagement)&top=100&skip=0"
+ $url -eq "https://test.vsaex.visualstudio.com/_apis/userentitlements/?api-version=$([VSTeamVersions]::MemberEntitlementManagement)&top=100&skip=0"
}
}
}
@@ -88,7 +88,7 @@ InModuleScope users {
# Make sure it was called with the correct URI
Assert-MockCalled _callAPI -Exactly 1 -ParameterFilter {
- $url -eq "https://test.vsaex.visualstudio.com/_apis/userentitlements/?api-version=$($VSTeamVersionTable.MemberEntitlementManagement)&top=100&skip=0&Select=Projects"
+ $url -eq "https://test.vsaex.visualstudio.com/_apis/userentitlements/?api-version=$([VSTeamVersions]::MemberEntitlementManagement)&top=100&skip=0&Select=Projects"
}
}
}
@@ -99,7 +99,7 @@ InModuleScope users {
$subDomain -eq 'vsaex' -and
$id -eq '00000000-0000-0000-0000-000000000000' -and
$resource -eq 'userentitlements' -and
- $version -eq $VSTeamVersionTable.MemberEntitlementManagement
+ $version -eq [VSTeamVersions]::MemberEntitlementManagement
}
Mock _callAPI {
@@ -119,7 +119,7 @@ InModuleScope users {
$id -eq '00000000-0000-0000-0000-000000000000' -and
$resource -eq 'userentitlements' -and
$method -eq 'Delete' -and
- $version -eq $VSTeamVersionTable.MemberEntitlementManagement
+ $version -eq [VSTeamVersions]::MemberEntitlementManagement
}
}
}
@@ -130,7 +130,7 @@ InModuleScope users {
$subDomain -eq 'vsaex' -and
$id -eq '00000000-0000-0000-0000-000000000000' -and
$resource -eq 'userentitlements' -and
- $version -eq $VSTeamVersionTable.MemberEntitlementManagement
+ $version -eq [VSTeamVersions]::MemberEntitlementManagement
}
Mock _callAPI {
@@ -153,7 +153,7 @@ InModuleScope users {
$subDomain -eq 'vsaex' -and
$id -eq '00000000-0000-0000-0000-000000000000' -and
$resource -eq 'userentitlements' -and
- $version -eq $VSTeamVersionTable.MemberEntitlementManagement
+ $version -eq [VSTeamVersions]::MemberEntitlementManagement
}
}
}
diff --git a/unit/test/workitem.Tests.ps1 b/unit/test/workitem.Tests.ps1
index 4dd8e7641..307ea1d9f 100644
--- a/unit/test/workitem.Tests.ps1
+++ b/unit/test/workitem.Tests.ps1
@@ -1,7 +1,7 @@
Set-StrictMode -Version Latest
InModuleScope workitems {
- $VSTeamVersionTable.Account = 'https://test.visualstudio.com'
+ [VSTeamVersions]::Account = 'https://test.visualstudio.com'
Describe 'workitems' {
# Mock the call to Get-Projects by the dynamic parameter for ProjectName
@@ -9,7 +9,7 @@ InModuleScope workitems {
$Uri -like "*_apis/projects*"
}
- . "$PSScriptRoot\mockProjectNameDynamicParamNoPSet.ps1"
+ . "$PSScriptRoot\mocks\mockProjectNameDynamicParamNoPSet.ps1"
$obj = @{
id = 47
@@ -34,7 +34,7 @@ InModuleScope workitems {
Assert-MockCalled Invoke-RestMethod -Exactly -Scope It -Times 1 -ParameterFilter {
$Method -eq 'Post' -and
$ContentType -eq 'application/json-patch+json' -and
- $Uri -eq "https://test.visualstudio.com/test/_apis/wit/workitems/`$Task?api-version=$($VSTeamVersionTable.Core)"
+ $Uri -eq "https://test.visualstudio.com/test/_apis/wit/workitems/`$Task?api-version=$([VSTeamVersions]::Core)"
}
}
@@ -45,7 +45,7 @@ InModuleScope workitems {
Assert-MockCalled Invoke-RestMethod -Exactly -Scope It -Times 1 -ParameterFilter {
$Method -eq 'Post' -and
$ContentType -eq 'application/json-patch+json' -and
- $Uri -eq "https://test.visualstudio.com/test/_apis/wit/workitems/`$Task?api-version=$($VSTeamVersionTable.Core)"
+ $Uri -eq "https://test.visualstudio.com/test/_apis/wit/workitems/`$Task?api-version=$([VSTeamVersions]::Core)"
}
}
}
@@ -78,10 +78,10 @@ InModuleScope workitems {
# matches I have to search for the portions I expect but can't
# assume the order.
# The general string should look like this:
- # https://test.visualstudio.com/test/_apis/wit/workitems/?api-version=$($VSTeamVersionTable.Core)&ids=47,48&`$Expand=None&errorPolicy=Fail
+ # https://test.visualstudio.com/test/_apis/wit/workitems/?api-version=$([VSTeamVersions]::Core)&ids=47,48&`$Expand=None&errorPolicy=Fail
Assert-MockCalled Invoke-RestMethod -Exactly -Scope It -Times 1 -ParameterFilter {
$Uri -like "*https://test.visualstudio.com/test/_apis/wit/workitems/*" -and
- $Uri -like "*api-version=$($VSTeamVersionTable.Core)*" -and
+ $Uri -like "*api-version=$([VSTeamVersions]::Core)*" -and
$Uri -like "*ids=47,48*" -and
$Uri -like "*`$Expand=None*" -and
$Uri -like "*errorPolicy=Fail*"
@@ -99,7 +99,7 @@ InModuleScope workitems {
Get-VSTeamWorkItem -ProjectName test -Id 47
Assert-MockCalled Invoke-RestMethod -Exactly -Scope It -Times 1 -ParameterFilter {
- $Uri -eq "https://test.visualstudio.com/test/_apis/wit/workitems/47?api-version=$($VSTeamVersionTable.Core)&`$Expand=None"
+ $Uri -eq "https://test.visualstudio.com/test/_apis/wit/workitems/47?api-version=$([VSTeamVersions]::Core)&`$Expand=None"
}
}
}
diff --git a/unit/test/workitemTypes.Tests.ps1 b/unit/test/workitemTypes.Tests.ps1
index d09dd2718..3ea41636a 100644
--- a/unit/test/workitemTypes.Tests.ps1
+++ b/unit/test/workitemTypes.Tests.ps1
@@ -6,7 +6,7 @@ InModuleScope workitemTypes {
# Set the account to use for testing. A normal user would do this
# using the Add-VSTeamAccount function.
- $VSTeamVersionTable.Account = 'https://test.visualstudio.com'
+ [VSTeamVersions]::Account = 'https://test.visualstudio.com'
Describe 'workitemTypes' {
# Mock the call to Get-Projects by the dynamic parameter for ProjectName
@@ -15,7 +15,7 @@ InModuleScope workitemTypes {
}
# Load the mocks to create the project name dynamic parameter
- . "$PSScriptRoot\mockProjectNameDynamicParam.ps1"
+ . "$PSScriptRoot\mocks\mockProjectNameDynamicParam.ps1"
Context 'Get-WorkItemTypes' {
$obj = @{
@@ -36,7 +36,7 @@ InModuleScope workitemTypes {
Get-VSTeamWorkItemType -ProjectName test
Assert-MockCalled Invoke-RestMethod -Exactly -Scope It -Times 1 -ParameterFilter {
- $Uri -eq "https://test.visualstudio.com/test/_apis/wit/workitemtypes/?api-version=$($VSTeamVersionTable.Core)"
+ $Uri -eq "https://test.visualstudio.com/test/_apis/wit/workitemtypes/?api-version=$([VSTeamVersions]::Core)"
}
}
}
@@ -58,7 +58,7 @@ InModuleScope workitemTypes {
Get-VSTeamWorkItemType -ProjectName test -WorkItemType bug
Assert-MockCalled Invoke-RestMethod -Exactly -Scope It -Times 1 -ParameterFilter {
- $Uri -eq "https://test.visualstudio.com/test/_apis/wit/workitemtypes/bug?api-version=$($VSTeamVersionTable.Core)"
+ $Uri -eq "https://test.visualstudio.com/test/_apis/wit/workitemtypes/bug?api-version=$([VSTeamVersions]::Core)"
}
}
}
@@ -80,7 +80,7 @@ InModuleScope workitemTypes {
Get-VSTeamWorkItemType -ProjectName test -WorkItemType bug
Assert-MockCalled Invoke-RestMethod -Exactly -Scope It -Times 1 -ParameterFilter {
- $Uri -eq "https://test.visualstudio.com/test/_apis/wit/workitemtypes/bug?api-version=$($VSTeamVersionTable.Core)"
+ $Uri -eq "https://test.visualstudio.com/test/_apis/wit/workitemtypes/bug?api-version=$([VSTeamVersions]::Core)"
}
}
}