Skip to content

Commit

Permalink
Merge pull request StartAutomating#78 from StartAutomating/Get-ADOTes…
Browse files Browse the repository at this point in the history
…tQuickFix

Fixing Get-ADOTest
  • Loading branch information
StartAutomating authored Apr 22, 2021
2 parents e5dd7af + 529c747 commit e41de13
Show file tree
Hide file tree
Showing 8 changed files with 175 additions and 45 deletions.
3 changes: 3 additions & 0 deletions Formatting/PSDevOps.TestPlan.format.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Write-FormatView -TypeName PSDevOps.TestPlan -Property Name, TestPlanID, Owner, State, AreaPath -Wrap -GroupByScript {
$_.Project.Name
} -GroupLabel ProjectName
6 changes: 6 additions & 0 deletions Formatting/PSDevOps.TestSuite.format.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Write-FormatView -TypeName PSDevOps.TestSuite -Property Name, TestSuiteID, LastUpdated, QueryString -Width 20, 12, 20, 0 -Wrap -GroupByProperty TestPlanName -VirtualProperty @{
LastUpdated = {
$_.LastUpdated.ToString('s')
}
}

82 changes: 38 additions & 44 deletions Get-ADOTest.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -10,101 +10,91 @@
Get-ADOTest -Run
.Link
Get-ADOProject
.Link
https://docs.microsoft.com/en-us/rest/api/azure/devops/test/runs/list
.Link
https://docs.microsoft.com/en-us/rest/api/azure/devops/test/test%20%20suites/list
.Link
https://docs.microsoft.com/en-us/rest/api/azure/devops/testplan/test%20%20suites/get%20test%20suites%20for%20plan
#>
[OutputType('PSDevOps.Project','PSDevOps.Property')]
param(
# The project identifier.
[Parameter(Mandatory,ValueFromPipelineByPropertyName,
ParameterSetName='/{Project}/_apis/test/runs')]
[Parameter(Mandatory,ValueFromPipelineByPropertyName,
ParameterSetName='/{Project}/_apis/test/runs/{TestRunID}')]
[Parameter(Mandatory,ValueFromPipelineByPropertyName,
ParameterSetName='/{Project}/_apis/test/runs/{TestRunID}/attachments')]
[Parameter(Mandatory,ValueFromPipelineByPropertyName,
ParameterSetName='/{Project}/_apis/test/runs/{TestRunID}/results')]
[Parameter(Mandatory,ValueFromPipelineByPropertyName,
ParameterSetName='/{Project}/_apis/test/plans/{TestPlanID}')]
[Parameter(Mandatory,ValueFromPipelineByPropertyName,
ParameterSetName='/{Project}/_apis/test/plans/{TestPlanID}/suites')]
[Parameter(Mandatory,ValueFromPipelineByPropertyName,
ParameterSetName='/{Project}/_apis/test/plans/{TestPlanID}/suites/{TestSuiteID}')]
[Parameter(Mandatory,ValueFromPipelineByPropertyName,
ParameterSetName='/{Project}/_apis/test/plans/{TestPlanID}/suites/{TestSuiteID}/points')]
[Parameter(Mandatory,ValueFromPipelineByPropertyName,
ParameterSetName='/{Project}/_apis/test/plans/variables')]
[Parameter(Mandatory,ValueFromPipelineByPropertyName,
ParameterSetName='/{Project}/_apis/test/plans/configurations')]
[Alias('ProjectID')]
[Parameter(Mandatory,ValueFromPipelineByPropertyName)]
[string]
$Project,
$ProjectID,

# If set, will return the test runs associated with a project.
[Parameter(ParameterSetName='/{Project}/_apis/test/runs')]
[Parameter(ParameterSetName='/{ProjectID}/_apis/test/runs')]
[Alias('TestRuns')]
[switch]
$TestRun,

# If set, will return results related to a specific test run.
[Parameter(Mandatory,ValueFromPipelineByPropertyName,ParameterSetName='/{Project}/_apis/test/runs/{TestRunID}')]
[Parameter(Mandatory,ValueFromPipelineByPropertyName,ParameterSetName='/{Project}/_apis/test/runs/{TestRunID}/attachments')]
[Parameter(Mandatory,ValueFromPipelineByPropertyName,ParameterSetName='/{ProjectID}/_apis/test/runs/{TestRunID}')]
[Parameter(Mandatory,ValueFromPipelineByPropertyName,ParameterSetName='/{ProjectID}/_apis/test/runs/{TestRunID}/attachments')]
[string]
$TestRunID,

# If set, will return the test plans associated with a project.
[Parameter(Mandatory,ParameterSetName='/{Project}/_apis/test/plans')]
[Parameter(Mandatory,ParameterSetName='/{ProjectID}/_apis/testplan/plans')]
[Alias('TestPlans')]
[switch]
$TestPlan,

# If set, will return results related to a specific test plan.
[Parameter(Mandatory,ValueFromPipelineByPropertyName,ParameterSetName='/{Project}/_apis/test/plans/{TestPlanID}')]
[Parameter(Mandatory,ValueFromPipelineByPropertyName,ParameterSetName='/{Project}/_apis/test/plans/{TestPlanID}/suites')]
[Parameter(Mandatory,ValueFromPipelineByPropertyName,
ParameterSetName='/{ProjectID}/_apis/testplan/{TestPlanID}')]
[Parameter(Mandatory,ValueFromPipelineByPropertyName,
ParameterSetName='/{ProjectID}/_apis/testplan/plans/{TestPlanID}/suites')]
[Parameter(Mandatory,ValueFromPipelineByPropertyName,
ParameterSetName='/{ProjectID}/_apis/testplan/plans/{TestPlanID}/suites/{TestSuiteID}/TestPoint')]
[string]
$TestPlanID,

# If set, will return the test variables associated with a project.
[Parameter(Mandatory,ParameterSetName='/{Project}/_apis/test/variables')]
[Parameter(Mandatory,ParameterSetName='/{ProjectID}/_apis/test/variables')]
[Alias('TestVariables')]
[switch]
$TestVariable,

# If set, will return the test variables associated with a project.
[Parameter(Mandatory,ParameterSetName='/{Project}/_apis/test/configurations')]
[Parameter(Mandatory,ParameterSetName='/{ProjectID}/_apis/test/configurations')]
[Alias('TestConfigurations')]
[switch]
$TestConfiguration,

# If set, will list test suites related to a plan.
[Parameter(Mandatory,ParameterSetName='/{Project}/_apis/test/plans/{TestPlanID}/suites')]
[Parameter(Mandatory,ParameterSetName='/{ProjectID}/_apis/testplan/plans/{TestPlanID}/suites')]
[Alias('TestSuites')]
[switch]
$TestSuite,

# If set, will return results related to a particular test suite.
[Parameter(Mandatory,ValueFromPipelineByPropertyName,
ParameterSetName='/{Project}/_apis/test/plans/{TestPlanID}/suites/{TestSuiteID}')]
ParameterSetName='/{ProjectID}/_apis/testplan/plans/{TestPlanID}/suites/{TestSuiteID}')]
[Parameter(Mandatory,ValueFromPipelineByPropertyName,
ParameterSetName='/{Project}/_apis/test/plans/{TestPlanID}/suites/{TestSuiteID}/points')]
ParameterSetName='/{ProjectID}/_apis/testplan/plans/{TestPlanID}/suites/{TestSuiteID}/TestPoint')]
[string]
$TestSuiteID,

# If set, will return test points within a suite.
[Parameter(Mandatory,
ParameterSetName='/{Project}/_apis/test/plans/{TestPlanID}/suites/{TestSuiteID}/points')]
ParameterSetName='/{ProjectID}/_apis/testplan/plans/{TestPlanID}/suites/{TestSuiteID}/TestPoint')]
[Alias('TestPoints')]
[switch]
$TestPoint,

# If set, will return test results within a run.
[Parameter(Mandatory,
ParameterSetName='/{Project}/_apis/test/runs/{TestRunID}/results')]
ParameterSetName='/{ProjectID}/_apis/test/runs/{TestRunID}/results')]
[Alias('TestResults')]
[switch]
$TestResult,

# If set, will return test attachments to a run.
[Parameter(Mandatory,
ParameterSetName='/{Project}/_apis/test/runs/{TestRunID}/attachment')]
ParameterSetName='/{ProjectID}/_apis/test/runs/{TestRunID}/attachments')]
[Alias('TestAttachments')]
[switch]
$TestAttachment,
Expand Down Expand Up @@ -133,14 +123,10 @@
#region Copy Invoke-ADORestAPI parameters
$invokeParams = . $getInvokeParameters $PSBoundParameters
#endregion Copy Invoke-ADORestAPI parameters
$baseParams = @{} + $invokeParams
$q = [Collections.Queue]::new()
}
process {
$in = $_
$psParameterSet = $psCmdlet.ParameterSetName

$q.Enqueue(@{PSParameterSet=$psParameterSet} + $PSBoundParameters)
$q.Enqueue(@{PSParameterSet=$psCmdlet.ParameterSetName;InputObject=$_} + $PSBoundParameters)
}
end {
$c, $t, $progId = 0, $q.Count, [Random]::new().Next()
Expand All @@ -167,15 +153,23 @@
Write-Progress "Getting" " [$c/$t] $uri" -PercentComplete ($c * 100 / $t) -Id $progId

$typeName = @($psParameterSet -split '/' -notlike '{*}')[-1] -replace
'\{' -replace '\}' -replace 'ies$', 'y' -replace 's$' -replace 'ID$' -replace
'(Plan|Run|Suite|Configuration|Point|Attachment|Result)', 'Test$0'
'\{' -replace '\}' -replace 'ies$', 'y' -replace 's$' -replace 'ID$' -replace
'TestPlan', 'Plan' -replace 'TestPoint','Point' -replace
'(Plan|Point|Run|Suite|Configuration|Attachment|Result)', 'Test$0'

$additionalProperty = @{
Organization = $Organization
Project = $Project
Server = $Server
}
if ($ProjectID) { $additionalProperty.ProjectID = $ProjectID }
if ($ProjectID) { $additionalProperty.ProjectID = $ProjectID }
if ($TestPlanID) {
$additionalProperty.TestPlanID = $TestPlanID
}
if ($inputObject.TestPlanName) {
$additionalProperty['TestPlanName'] = $inputObject.TestPlanName
}
if ($TestSuiteID) { $additionalProperty.TestSuiteID = $TestSuiteID }
Invoke-ADORestAPI @invokeParams -uri $uri -PSTypeName "$Organization.$typeName",
"PSDevOps.$typeName" -Property $additionalProperty
}
Expand Down
98 changes: 98 additions & 0 deletions PSDevOps.format.ps1xml
Original file line number Diff line number Diff line change
Expand Up @@ -1090,6 +1090,54 @@ $($ParentNode.CustomControl.CustomEntries.CustomEntry.CustomItem.ExpressionBindi
</TableRowEntries>
</TableControl>
</View>
<View>
<Name>PSDevOps.TestPlan</Name>
<ViewSelectedBy>
<TypeName>PSDevOps.TestPlan</TypeName>
</ViewSelectedBy>
<GroupBy>
<ScriptBlock>
$_.Project.Name
</ScriptBlock>
<Label>ProjectName</Label>
</GroupBy>
<TableControl>
<TableHeaders>
<TableColumnHeader>
</TableColumnHeader>
<TableColumnHeader>
</TableColumnHeader>
<TableColumnHeader>
</TableColumnHeader>
<TableColumnHeader>
</TableColumnHeader>
<TableColumnHeader>
</TableColumnHeader>
</TableHeaders>
<TableRowEntries>
<TableRowEntry>
<Wrap />
<TableColumnItems>
<TableColumnItem>
<PropertyName>Name</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>TestPlanID</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>Owner</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>State</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>AreaPath</PropertyName>
</TableColumnItem>
</TableColumnItems>
</TableRowEntry>
</TableRowEntries>
</TableControl>
</View>
<View>
<Name>PSDevOps.TestRun</Name>
<ViewSelectedBy>
Expand Down Expand Up @@ -1250,6 +1298,56 @@ $($ParentNode.CustomControl.CustomEntries.CustomEntry.CustomItem.ExpressionBindi
</TableRowEntries>
</TableControl>
</View>
<View>
<Name>PSDevOps.TestSuite</Name>
<ViewSelectedBy>
<TypeName>PSDevOps.TestSuite</TypeName>
</ViewSelectedBy>
<GroupBy>
<PropertyName>TestPlanName</PropertyName>
</GroupBy>
<TableControl>
<TableHeaders>
<TableColumnHeader>
<Alignment>left</Alignment>
<Width>20</Width>
</TableColumnHeader>
<TableColumnHeader>
<Alignment>left</Alignment>
<Width>12</Width>
</TableColumnHeader>
<TableColumnHeader>
<Label>LastUpdated</Label>
<Alignment>left</Alignment>
<Width>20</Width>
</TableColumnHeader>
<TableColumnHeader>
<Alignment>left</Alignment>
</TableColumnHeader>
</TableHeaders>
<TableRowEntries>
<TableRowEntry>
<Wrap />
<TableColumnItems>
<TableColumnItem>
<PropertyName>Name</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>TestSuiteID</PropertyName>
</TableColumnItem>
<TableColumnItem>
<ScriptBlock>
$_.LastUpdated.ToString('s')
</ScriptBlock>
</TableColumnItem>
<TableColumnItem>
<PropertyName>QueryString</PropertyName>
</TableColumnItem>
</TableColumnItems>
</TableRowEntry>
</TableRowEntries>
</TableControl>
</View>
<View>
<Name>PSDevOps.Wiki</Name>
<ViewSelectedBy>
Expand Down
7 changes: 6 additions & 1 deletion PSDevOps.psd1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@{
ModuleVersion = '0.5'
ModuleVersion = '0.5.1'
RootModule = 'PSDevOps.psm1'
Description = 'PowerShell Tools for DevOps'
Guid = 'e6b56c5f-41ac-4ba4-8b88-2c063f683176'
Expand All @@ -9,6 +9,11 @@
ProjectURI = 'https://github.com/StartAutomating/PSDevOps'
LicenseURI = 'https://github.com/StartAutomating/PSDevOps/blob/master/LICENSE'
ReleaseNotes = @'
0.5.1
---
* Bugfixes:
** Get-ADOTest: Fixing parameter sets and adding formatting.
** Invoke-GitHubRESTAPI: Only using .ContentEncoding when present.
0.5
---
* Improved Git Functionality
Expand Down
22 changes: 22 additions & 0 deletions PSDevOps.types.ps1xml
Original file line number Diff line number Diff line change
Expand Up @@ -1120,6 +1120,10 @@ $bitMask
<Name>TestPlanID</Name>
<ReferencedMemberName>ID</ReferencedMemberName>
</AliasProperty>
<AliasProperty>
<Name>TestPlanName</Name>
<ReferencedMemberName>Name</ReferencedMemberName>
</AliasProperty>
</Members>
</Type>
<Type>
Expand All @@ -1129,6 +1133,10 @@ $bitMask
<Name>TestPlanID</Name>
<ReferencedMemberName>ID</ReferencedMemberName>
</AliasProperty>
<AliasProperty>
<Name>TestPlanName</Name>
<ReferencedMemberName>Name</ReferencedMemberName>
</AliasProperty>
</Members>
</Type>
<Type>
Expand Down Expand Up @@ -1174,6 +1182,13 @@ $bitMask
<Name>TestSuiteID</Name>
<ReferencedMemberName>ID</ReferencedMemberName>
</AliasProperty>
<ScriptProperty>
<Name>LastUpdated</Name>
<GetScriptBlock>
[DateTime]$this.LastUpdatedDate

</GetScriptBlock>
</ScriptProperty>
</Members>
</Type>
<Type>
Expand All @@ -1183,6 +1198,13 @@ $bitMask
<Name>TestSuiteID</Name>
<ReferencedMemberName>ID</ReferencedMemberName>
</AliasProperty>
<ScriptProperty>
<Name>LastUpdated</Name>
<GetScriptBlock>
[DateTime]$this.LastUpdatedDate

</GetScriptBlock>
</ScriptProperty>
</Members>
</Type>
<Type>
Expand Down
1 change: 1 addition & 0 deletions Types/PSDevOps.TestPlan/Alias.psd1
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@{
TestPlanID = 'ID'
TestPlanName = 'Name'
}
1 change: 1 addition & 0 deletions Types/PSDevOps.TestSuite/get_LastUpdated.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[DateTime]$this.LastUpdatedDate

0 comments on commit e41de13

Please sign in to comment.