Skip to content

Commit c3d8ba0

Browse files
committed
Unit tests for all DeploymentPipeline functions
1 parent 01c2bb0 commit c3d8ba0

16 files changed

Lines changed: 509 additions & 5 deletions

helper/build-and-test.ps1

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ Get-Module Fab*
1818
Invoke-ScriptAnalyzer -Path .\source\Public\**
1919

2020

21-
$tests = Invoke-Pester .\tests\ -PassThru
2221
$tests = Invoke-Pester .\tests\ -PassThru
2322
$tests.Tests | where Result -eq 'Failed' | Measure-Object | Select-Object -ExpandProperty Count
2423
$tests.Tests | where Result -eq 'Failed' | ft -Property ExpandedName, ErrorRecord
2524
$tests.Tests | where Result -eq 'Failed' | ft -Property Name, Result, ErrorRecord -AutoSize
25+
26+
$e = $tests.Tests | where Result -eq 'Failed' | Select-Object -First 1
27+
$e.ErrorRecord

source/Private/Get-FabricContinuationToken.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ It returns the continuation token variable and provides debug logging.
1010
The API response object that may contain a continuation token.
1111
1212
.EXAMPLE
13-
Get-FabricContinuationToken -Response $response -ContinuationToken $continuationToken
13+
Get-FabricContinuationToken -Response $response
1414
1515
Processes the response and returns the continuation token if present.
1616

source/Public/Deployment Pipeline/Get-FabricDeploymentPipeline.ps1

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ It automatically handles pagination when retrieving all pipelines.
1010
.PARAMETER DeploymentPipelineId
1111
Optional. The ID of a specific deployment pipeline to retrieve. If not provided, all pipelines will be retrieved.
1212
13+
.PARAMETER DeploymentPipelineName
14+
Optional. The display name of a specific deployment pipeline to retrieve. If provided, it will filter the results to match this name.
15+
1316
.EXAMPLE
1417
Get-FabricDeploymentPipeline
1518

source/Public/Deployment Pipeline/Remove-FabricWorkspaceFromStage.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Author: Kamil Nowinski
2828
#>
2929

3030
function Remove-FabricWorkspaceFromStage {
31-
[CmdletBinding()]
31+
[CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'High')]
3232
param(
3333
[Parameter(Mandatory = $true)]
3434
[ValidateNotNullOrEmpty()]

tests/QA/module.tests.ps1

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,10 +228,11 @@ Describe 'Help for module' -Tags 'helpQuality' {
228228
}
229229
}
230230

231-
Describe "datatypes for functions" -Tag "ParameterTypes" {
231+
Describe "Data Types for functions" -Tag "ParameterTypes" {
232232
$tests = $allModuleFunctions | Where-Object -FilterScript {
233233
$_.Name -notin (
234-
'Get-FabricLongRunningOperation'
234+
'Get-FabricLongRunningOperation',
235+
'Get-FabricDeploymentPipelineStage'
235236
)
236237
} | ForEach-Object {
237238
[PSCustomObject]@{
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#Requires -Module @{ ModuleName="Pester"; ModuleVersion="5.0"}
2+
param(
3+
$ModuleName = "FabricTools",
4+
$expectedParams = @(
5+
"DeploymentPipelineId"
6+
"StageId"
7+
"WorkspaceId"
8+
"Verbose"
9+
"Debug"
10+
"ErrorAction"
11+
"WarningAction"
12+
"InformationAction"
13+
"ProgressAction"
14+
"ErrorVariable"
15+
"WarningVariable"
16+
"InformationVariable"
17+
"OutVariable"
18+
"OutBuffer"
19+
"PipelineVariable"
20+
)
21+
)
22+
23+
Describe "Add-FabricWorkspaceToStage" -Tag "UnitTests" {
24+
25+
BeforeDiscovery {
26+
$command = Get-Command -Name Add-FabricWorkspaceToStage
27+
$expected = $expectedParams
28+
}
29+
30+
Context "Parameter validation" {
31+
BeforeAll {
32+
$command = Get-Command -Name Add-FabricWorkspaceToStage
33+
$expected = $expectedParams
34+
}
35+
36+
It "Has parameter: <_>" -ForEach $expected {
37+
$command | Should -HaveParameter $PSItem
38+
}
39+
40+
It "Should have exactly the number of expected parameters $($expected.Count)" {
41+
$hasParams = $command.Parameters.Values.Name
42+
Compare-Object -ReferenceObject $expected -DifferenceObject $hasParams | Should -BeNullOrEmpty
43+
}
44+
}
45+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#Requires -Module @{ ModuleName="Pester"; ModuleVersion="5.0"}
2+
3+
InModuleScope FabricTools {
4+
5+
param(
6+
$ModuleName = "FabricTools",
7+
$expectedParams = @(
8+
"Response"
9+
"Verbose"
10+
"Debug"
11+
"ErrorAction"
12+
"WarningAction"
13+
"InformationAction"
14+
"ProgressAction"
15+
"ErrorVariable"
16+
"WarningVariable"
17+
"InformationVariable"
18+
"OutVariable"
19+
"OutBuffer"
20+
"PipelineVariable"
21+
)
22+
)
23+
24+
Describe "Get-FabricContinuationToken" -Tag "UnitTests" {
25+
26+
BeforeDiscovery {
27+
ipmo ".\output\module\FabricTools\0.0.1\FabricTools.psd1"
28+
29+
$command = Get-Command -Name Get-FabricContinuationToken
30+
$script:expected = $expectedParams
31+
}
32+
33+
Context "Parameter validation" {
34+
BeforeAll {
35+
$command = Get-Command -Name Get-FabricContinuationToken
36+
$expected = $expectedParams
37+
}
38+
39+
It "Has parameter: <_>" -ForEach $expected {
40+
$command | Should -HaveParameter $PSItem
41+
}
42+
43+
It "Should have exactly the number of expected parameters $($expected.Count)" {
44+
$hasParams = $command.Parameters.Values.Name
45+
Compare-Object -ReferenceObject $script:expected -DifferenceObject $hasParams | Should -BeNullOrEmpty
46+
}
47+
}
48+
}
49+
50+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#Requires -Module @{ ModuleName="Pester"; ModuleVersion="5.0"}
2+
param(
3+
$ModuleName = "FabricTools",
4+
$expectedParams = @(
5+
"DeploymentPipelineId"
6+
"DeploymentPipelineName"
7+
"Verbose"
8+
"Debug"
9+
"ErrorAction"
10+
"WarningAction"
11+
"InformationAction"
12+
"ProgressAction"
13+
"ErrorVariable"
14+
"WarningVariable"
15+
"InformationVariable"
16+
"OutVariable"
17+
"OutBuffer"
18+
"PipelineVariable"
19+
)
20+
)
21+
22+
Describe "Get-FabricDeploymentPipeline" -Tag "UnitTests" {
23+
24+
BeforeDiscovery {
25+
$command = Get-Command -Name Get-FabricDeploymentPipeline
26+
$expected = $expectedParams
27+
}
28+
29+
Context "Parameter validation" {
30+
BeforeAll {
31+
$command = Get-Command -Name Get-FabricDeploymentPipeline
32+
$expected = $expectedParams
33+
}
34+
35+
It "Has parameter: <_>" -ForEach $expected {
36+
$command | Should -HaveParameter $PSItem
37+
}
38+
39+
It "Should have exactly the number of expected parameters $($expected.Count)" {
40+
$hasParams = $command.Parameters.Values.Name
41+
Compare-Object -ReferenceObject $expected -DifferenceObject $hasParams | Should -BeNullOrEmpty
42+
}
43+
}
44+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#Requires -Module @{ ModuleName="Pester"; ModuleVersion="5.0"}
2+
param(
3+
$ModuleName = "FabricTools",
4+
$expectedParams = @(
5+
"DeploymentPipelineId"
6+
"OperationId"
7+
"Verbose"
8+
"Debug"
9+
"ErrorAction"
10+
"WarningAction"
11+
"InformationAction"
12+
"ProgressAction"
13+
"ErrorVariable"
14+
"WarningVariable"
15+
"InformationVariable"
16+
"OutVariable"
17+
"OutBuffer"
18+
"PipelineVariable"
19+
)
20+
)
21+
22+
Describe "Get-FabricDeploymentPipelineOperation" -Tag "UnitTests" {
23+
24+
BeforeDiscovery {
25+
$command = Get-Command -Name Get-FabricDeploymentPipelineOperation
26+
$expected = $expectedParams
27+
}
28+
29+
Context "Parameter validation" {
30+
BeforeAll {
31+
$command = Get-Command -Name Get-FabricDeploymentPipelineOperation
32+
$expected = $expectedParams
33+
}
34+
35+
It "Has parameter: <_>" -ForEach $expected {
36+
$command | Should -HaveParameter $PSItem
37+
}
38+
39+
It "Should have exactly the number of expected parameters $($expected.Count)" {
40+
$hasParams = $command.Parameters.Values.Name
41+
Compare-Object -ReferenceObject $expected -DifferenceObject $hasParams | Should -BeNullOrEmpty
42+
}
43+
}
44+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#Requires -Module @{ ModuleName="Pester"; ModuleVersion="5.0"}
2+
param(
3+
$ModuleName = "FabricTools",
4+
$expectedParams = @(
5+
"DeploymentPipelineId"
6+
"Verbose"
7+
"Debug"
8+
"ErrorAction"
9+
"WarningAction"
10+
"InformationAction"
11+
"ProgressAction"
12+
"ErrorVariable"
13+
"WarningVariable"
14+
"InformationVariable"
15+
"OutVariable"
16+
"OutBuffer"
17+
"PipelineVariable"
18+
)
19+
)
20+
21+
Describe "Get-FabricDeploymentPipelineRoleAssignments" -Tag "UnitTests" {
22+
23+
BeforeDiscovery {
24+
$command = Get-Command -Name Get-FabricDeploymentPipelineRoleAssignments
25+
$expected = $expectedParams
26+
}
27+
28+
Context "Parameter validation" {
29+
BeforeAll {
30+
$command = Get-Command -Name Get-FabricDeploymentPipelineRoleAssignments
31+
$expected = $expectedParams
32+
}
33+
34+
It "Has parameter: <_>" -ForEach $expected {
35+
$command | Should -HaveParameter $PSItem
36+
}
37+
38+
It "Should have exactly the number of expected parameters $($expected.Count)" {
39+
$hasParams = $command.Parameters.Values.Name
40+
Compare-Object -ReferenceObject $expected -DifferenceObject $hasParams | Should -BeNullOrEmpty
41+
}
42+
}
43+
}

0 commit comments

Comments
 (0)