File tree Expand file tree Collapse file tree 2 files changed +20
-4
lines changed Expand file tree Collapse file tree 2 files changed +20
-4
lines changed Original file line number Diff line number Diff line change @@ -74,7 +74,11 @@ function Test-FabricApiResponse {
74
74
if ($NoWait ) {
75
75
Write-Message - Message " NoWait parameter is set. Operation ID: $operationId " - Level Info
76
76
Write-Message - Message " Run to check the progress: Get-FabricLongRunningOperationResult -operationId '$operationId '" - Level Verbose
77
- return $responseHeader
77
+ return [PSCustomObject ]@ {
78
+ Location = $responseHeader [" Location" ]
79
+ RetryAfter = $responseHeader [" Retry-After" ]
80
+ OperationId = $responseHeader [" x-ms-operation-id" ]
81
+ }
78
82
}
79
83
80
84
Write-Message - Message " [Test-FabricApiResponse] Operation ID: '$operationId '" - Level Debug
Original file line number Diff line number Diff line change @@ -55,7 +55,11 @@ Describe "Test-FabricApiResponse - StatusCode Handling" -Tag "UnitTests" {
55
55
56
56
BeforeAll {
57
57
# Generate a random GUID for x-ms-operation-id
58
- $script :responseHeader = @ { " x-ms-operation-id" = [guid ]::NewGuid().ToString() }
58
+ $script :responseHeader = @ {
59
+ " x-ms-operation-id" = [guid ]::NewGuid().ToString()
60
+ " Location" = " https://api.fabric.microsoft.com/v1/operations/$ ( [guid ]::NewGuid().ToString()) "
61
+ " Retry-After" = 30
62
+ }
59
63
$script :response = @ { " foo" = " bar" }
60
64
}
61
65
@@ -91,10 +95,18 @@ Describe "Test-FabricApiResponse - StatusCode Handling" -Tag "UnitTests" {
91
95
Should - Invoke Get-FabricLongRunningOperationResult - Exactly 1
92
96
}
93
97
94
- It " Returns responseHeader when statusCode is 202 and -NoWait is specified" {
98
+ It " Returns PSCustomObject with 3 properties when statusCode is 202 and -NoWait is specified" {
95
99
$script :statusCode = 202
96
100
$result = Test-FabricApiResponse - Response $script :response - NoWait
97
- $result | Should - Be $script :responseHeader
101
+
102
+ $expected = [PSCustomObject ]@ {
103
+ Location = $script :responseHeader.Location
104
+ RetryAfter = $script :responseHeader .' Retry-After'
105
+ OperationId = $script :responseHeader .' x-ms-operation-id'
106
+ }
107
+ $result.Location | Should - Be $expected.Location
108
+ $result.RetryAfter | Should - Be $expected.RetryAfter
109
+ $result.OperationId | Should - Be $expected.OperationId
98
110
}
99
111
100
112
It " Throws when statusCode is not 200, 201, or 202" {
You can’t perform that action at this time.
0 commit comments