Skip to content

Commit f41fe6c

Browse files
committed
more tests
1 parent 41e373b commit f41fe6c

8 files changed

+101
-17
lines changed

src/Support/Support.Autorest/custom/New-AzSupportFileAndUpload.ps1

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ param(
129129

130130
process {
131131
$ErrorActionPreference = 'Stop'
132-
Write-Output "file path: " $FilePath
132+
#Write-Output "file path: " + $FilePath
133133
$MaxChunkSize = 2.5 * 1024 * 1024 #2.5 MB
134134
$MaxFileSize = 5 * 1024 * 1024 #5 MB
135135
$FileContentBytes = Get-Content -Path $FilePath -Raw
@@ -142,15 +142,15 @@ process {
142142
throw "File size is greater than the maximum file size of 5 MB"
143143
}
144144
$ChunkSize = If($FileSize -gt $MaxChunkSize) {$MaxChunkSize} Else {$FileSize}
145-
Write-Output "Length of byte array: " $FileSize
146-
Write-Output "Max chunk size: " $MaxChunkSize
147-
Write-Output "Chunk Size: " $ChunkSize
145+
# Write-Output "Length of byte array: " $FileSize
146+
# Write-Output "Max chunk size: " $MaxChunkSize
147+
# Write-Output "Chunk Size: " $ChunkSize
148148
$NumberOfChunks = [int][Math]::Floor($FileSize / $ChunkSize);
149149
If($FileSize % $ChunkSize -gt 0)
150150
{
151151
$NumberOfChunks++
152152
}
153-
Write-Output "Number of chunks: " $NumberOfChunks
153+
# Write-Output "Number of chunks: " $NumberOfChunks
154154

155155
New-AzSupportFile -SubscriptionId $SubscriptionId -Name $Name -WorkspaceName $WorkspaceName -FileSize $FileSize -ChunkSize $ChunkSize -NumberOfChunk $NumberOfChunks
156156

@@ -162,9 +162,9 @@ process {
162162
# $FileContent = [convert]::ToBase64String((Get-Content -path $FilePath -Encoding byte))
163163

164164
while($chunkIndex -lt $NumberOfChunks){
165-
Write-Output "chunk index: " + $chunkIndex
166-
Write-Output "start index: " + $startIndex
167-
Write-Output "end index: " + $endIndex
165+
# Write-Output "chunk index: " + $chunkIndex
166+
# Write-Output "start index: " + $startIndex
167+
# Write-Output "end index: " + $endIndex
168168
$FileContent = [convert]::ToBase64String($FileContentByteArray[$startIndex..$endIndex])
169169

170170
Invoke-AzSupportUploadFile -SubscriptionId $SubscriptionId -FileName $Name -FileWorkspaceName $WorkspaceName -ChunkIndex $chunkIndex -Content $FileContent

src/Support/Support.Autorest/test/New-AzSupportFileAndUpload.Tests.ps1

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@ if(($null -eq $TestName) -or ($TestName -contains 'New-AzSupportFileAndUpload'))
1515
}
1616

1717
Describe 'New-AzSupportFileAndUpload' {
18-
It 'CreateExpanded' -skip {
19-
{ throw [System.NotImplementedException] } | Should -Not -Throw
18+
It 'CreateExpanded' {
19+
Write-Host "current path: " + $currentPath
20+
Write-Host "ps script root: " + $PSScriptRoot
21+
$testFilePath = Join-Path $PSScriptRoot files test.txt
22+
Write-Host "test file path: " + $testFilePath
23+
$file = New-AzSupportFileAndUpload -Name "test.txt" -WorkspaceName $env.FileWorkspaceNameSubscription -FilePath $testFilePath
24+
$file.Name | Should -Be "test.txt"
2025
}
2126
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"Test-AzSupportTicketNameAvailability+[NoContext]+CheckExpanded+$POST+https://management.azure.com/subscriptions/4df09db9-7a7e-450b-8f88-00fb97c277bd/providers/Microsoft.Support/checkNameAvailability?api-version=2022-09-01-preview+1": {
3+
"Request": {
4+
"Method": "POST",
5+
"RequestUri": "https://management.azure.com/subscriptions/4df09db9-7a7e-450b-8f88-00fb97c277bd/providers/Microsoft.Support/checkNameAvailability?api-version=2022-09-01-preview",
6+
"Content": "{\r\n \"name\": \"test-ps-42dbecba-4472-40af-9db4-1c0f1e9780a1\",\r\n \"type\": \"Microsoft.Support/supportTickets\"\r\n}",
7+
"isContentBase64": false,
8+
"Headers": {
9+
},
10+
"ContentHeaders": {
11+
"Content-Type": [ "application/json" ],
12+
"Content-Length": [ "109" ]
13+
}
14+
},
15+
"Response": {
16+
"StatusCode": 200,
17+
"Headers": {
18+
"Cache-Control": [ "no-cache" ],
19+
"Pragma": [ "no-cache" ],
20+
"X-Content-Type-Options": [ "nosniff" ],
21+
"Strict-Transport-Security": [ "max-age=31536000; includeSubDomains" ],
22+
"Server": [ "Kestrel" ],
23+
"x-ms-ratelimit-remaining-subscription-writes": [ "1199" ],
24+
"x-ms-request-id": [ "2f30b178-d575-4095-9ee7-4ac5f905706f" ],
25+
"x-ms-correlation-request-id": [ "2f30b178-d575-4095-9ee7-4ac5f905706f" ],
26+
"x-ms-routing-request-id": [ "EASTUS:20240130T171835Z:2f30b178-d575-4095-9ee7-4ac5f905706f" ],
27+
"Date": [ "Tue, 30 Jan 2024 17:18:35 GMT" ]
28+
},
29+
"ContentHeaders": {
30+
"Content-Length": [ "22" ],
31+
"Content-Type": [ "application/json; charset=utf-8" ],
32+
"Expires": [ "-1" ]
33+
},
34+
"Content": "{\"nameAvailable\":true}",
35+
"isContentBase64": false
36+
}
37+
}
38+
}

src/Support/Support.Autorest/test/Test-AzSupportTicketNameAvailability.Tests.ps1

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ if(($null -eq $TestName) -or ($TestName -contains 'Test-AzSupportTicketNameAvail
1515
}
1616

1717
Describe 'Test-AzSupportTicketNameAvailability' {
18-
It 'CheckExpanded' -skip {
19-
{ throw [System.NotImplementedException] } | Should -Not -Throw
18+
It 'CheckExpanded' {
19+
$result = Test-AzSupportTicketNameAvailability -Name "test-ps-$(New-Guid)" -Type "Microsoft.Support/supportTickets"-SubscriptionId $env.SubscriptionId
20+
$result.NameAvailable | Should -Be $true
2021
}
2122

2223
It 'Check' -skip {
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"Test-AzSupportTicketsNoSubscriptionNameAvailability+[NoContext]+CheckExpanded+$POST+https://management.azure.com/providers/Microsoft.Support/checkNameAvailability?api-version=2022-09-01-preview+1": {
3+
"Request": {
4+
"Method": "POST",
5+
"RequestUri": "https://management.azure.com/providers/Microsoft.Support/checkNameAvailability?api-version=2022-09-01-preview",
6+
"Content": "{\r\n \"name\": \"test-ps-f0f0df36-66f3-4f4e-9686-80a68bb9d53d\",\r\n \"type\": \"Microsoft.Support/supportTickets\"\r\n}",
7+
"isContentBase64": false,
8+
"Headers": {
9+
},
10+
"ContentHeaders": {
11+
"Content-Type": [ "application/json" ],
12+
"Content-Length": [ "109" ]
13+
}
14+
},
15+
"Response": {
16+
"StatusCode": 200,
17+
"Headers": {
18+
"Cache-Control": [ "no-cache" ],
19+
"Pragma": [ "no-cache" ],
20+
"X-Content-Type-Options": [ "nosniff" ],
21+
"Strict-Transport-Security": [ "max-age=31536000; includeSubDomains" ],
22+
"Server": [ "Kestrel" ],
23+
"x-ms-ratelimit-remaining-tenant-writes": [ "1199" ],
24+
"x-ms-request-id": [ "746f8be3-9ba4-4323-93fa-3567dff84f3f" ],
25+
"x-ms-correlation-request-id": [ "746f8be3-9ba4-4323-93fa-3567dff84f3f" ],
26+
"x-ms-routing-request-id": [ "EASTUS:20240130T172214Z:746f8be3-9ba4-4323-93fa-3567dff84f3f" ],
27+
"Date": [ "Tue, 30 Jan 2024 17:22:14 GMT" ]
28+
},
29+
"ContentHeaders": {
30+
"Content-Length": [ "22" ],
31+
"Content-Type": [ "application/json; charset=utf-8" ],
32+
"Expires": [ "-1" ]
33+
},
34+
"Content": "{\"nameAvailable\":true}",
35+
"isContentBase64": false
36+
}
37+
}
38+
}

src/Support/Support.Autorest/test/Test-AzSupportTicketsNoSubscriptionNameAvailability.Tests.ps1

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ if(($null -eq $TestName) -or ($TestName -contains 'Test-AzSupportTicketsNoSubscr
1515
}
1616

1717
Describe 'Test-AzSupportTicketsNoSubscriptionNameAvailability' {
18-
It 'CheckExpanded' -skip {
19-
{ throw [System.NotImplementedException] } | Should -Not -Throw
18+
It 'CheckExpanded' {
19+
$result = Test-AzSupportTicketsNoSubscriptionNameAvailability -Name "test-ps-$(New-Guid)" -Type "Microsoft.Support/supportTickets"
20+
$result.NameAvailable | Should -Be $true
2021
}
2122

2223
It 'Check' -skip {
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
2-
"BillingProblemClassificationId": "d0f16bf7-e011-3f3b-1c26-3147f84e0896",
32
"BillingServiceId": "517f2da6-78fd-0498-4e22-ad26996b1dfc",
3+
"BillingProblemClassificationId": "d0f16bf7-e011-3f3b-1c26-3147f84e0896",
44
"Tenant": "d71d46f6-114f-4d2a-81c9-8fc86ba8801c",
5-
"FileWorkspaceNameNoSubscription": "test-ps-43ad6585-c0ac-4a13-8d0e-bb633b8b1db3",
5+
"FileWorkspaceNameNoSubscription": "test-ps-94021760-e8a2-4995-85d4-13e6b443eddb",
66
"SubscriptionId": "4df09db9-7a7e-450b-8f88-00fb97c277bd",
7-
"FileWorkspaceNameSubscription": "test-ps-d4adfb8c-f15c-48de-a0b0-8da419bfe51d"
7+
"FileWorkspaceNameSubscription": "test-ps-515d6c7e-beb8-4617-8325-cfd236c4bc5b"
88
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
test

0 commit comments

Comments
 (0)