Skip to content

Commit

Permalink
more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
grhuangmsft committed Jan 30, 2024
1 parent 41e373b commit f41fe6c
Show file tree
Hide file tree
Showing 8 changed files with 101 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ param(

process {
$ErrorActionPreference = 'Stop'
Write-Output "file path: " $FilePath
#Write-Output "file path: " + $FilePath
$MaxChunkSize = 2.5 * 1024 * 1024 #2.5 MB
$MaxFileSize = 5 * 1024 * 1024 #5 MB
$FileContentBytes = Get-Content -Path $FilePath -Raw
Expand All @@ -142,15 +142,15 @@ process {
throw "File size is greater than the maximum file size of 5 MB"
}
$ChunkSize = If($FileSize -gt $MaxChunkSize) {$MaxChunkSize} Else {$FileSize}
Write-Output "Length of byte array: " $FileSize
Write-Output "Max chunk size: " $MaxChunkSize
Write-Output "Chunk Size: " $ChunkSize
# Write-Output "Length of byte array: " $FileSize
# Write-Output "Max chunk size: " $MaxChunkSize
# Write-Output "Chunk Size: " $ChunkSize
$NumberOfChunks = [int][Math]::Floor($FileSize / $ChunkSize);
If($FileSize % $ChunkSize -gt 0)
{
$NumberOfChunks++
}
Write-Output "Number of chunks: " $NumberOfChunks
# Write-Output "Number of chunks: " $NumberOfChunks

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

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

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

Invoke-AzSupportUploadFile -SubscriptionId $SubscriptionId -FileName $Name -FileWorkspaceName $WorkspaceName -ChunkIndex $chunkIndex -Content $FileContent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ if(($null -eq $TestName) -or ($TestName -contains 'New-AzSupportFileAndUpload'))
}

Describe 'New-AzSupportFileAndUpload' {
It 'CreateExpanded' -skip {
{ throw [System.NotImplementedException] } | Should -Not -Throw
It 'CreateExpanded' {
Write-Host "current path: " + $currentPath
Write-Host "ps script root: " + $PSScriptRoot
$testFilePath = Join-Path $PSScriptRoot files test.txt
Write-Host "test file path: " + $testFilePath
$file = New-AzSupportFileAndUpload -Name "test.txt" -WorkspaceName $env.FileWorkspaceNameSubscription -FilePath $testFilePath
$file.Name | Should -Be "test.txt"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"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": {
"Request": {
"Method": "POST",
"RequestUri": "https://management.azure.com/subscriptions/4df09db9-7a7e-450b-8f88-00fb97c277bd/providers/Microsoft.Support/checkNameAvailability?api-version=2022-09-01-preview",
"Content": "{\r\n \"name\": \"test-ps-42dbecba-4472-40af-9db4-1c0f1e9780a1\",\r\n \"type\": \"Microsoft.Support/supportTickets\"\r\n}",
"isContentBase64": false,
"Headers": {
},
"ContentHeaders": {
"Content-Type": [ "application/json" ],
"Content-Length": [ "109" ]
}
},
"Response": {
"StatusCode": 200,
"Headers": {
"Cache-Control": [ "no-cache" ],
"Pragma": [ "no-cache" ],
"X-Content-Type-Options": [ "nosniff" ],
"Strict-Transport-Security": [ "max-age=31536000; includeSubDomains" ],
"Server": [ "Kestrel" ],
"x-ms-ratelimit-remaining-subscription-writes": [ "1199" ],
"x-ms-request-id": [ "2f30b178-d575-4095-9ee7-4ac5f905706f" ],
"x-ms-correlation-request-id": [ "2f30b178-d575-4095-9ee7-4ac5f905706f" ],
"x-ms-routing-request-id": [ "EASTUS:20240130T171835Z:2f30b178-d575-4095-9ee7-4ac5f905706f" ],
"Date": [ "Tue, 30 Jan 2024 17:18:35 GMT" ]
},
"ContentHeaders": {
"Content-Length": [ "22" ],
"Content-Type": [ "application/json; charset=utf-8" ],
"Expires": [ "-1" ]
},
"Content": "{\"nameAvailable\":true}",
"isContentBase64": false
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ if(($null -eq $TestName) -or ($TestName -contains 'Test-AzSupportTicketNameAvail
}

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

It 'Check' -skip {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"Test-AzSupportTicketsNoSubscriptionNameAvailability+[NoContext]+CheckExpanded+$POST+https://management.azure.com/providers/Microsoft.Support/checkNameAvailability?api-version=2022-09-01-preview+1": {
"Request": {
"Method": "POST",
"RequestUri": "https://management.azure.com/providers/Microsoft.Support/checkNameAvailability?api-version=2022-09-01-preview",
"Content": "{\r\n \"name\": \"test-ps-f0f0df36-66f3-4f4e-9686-80a68bb9d53d\",\r\n \"type\": \"Microsoft.Support/supportTickets\"\r\n}",
"isContentBase64": false,
"Headers": {
},
"ContentHeaders": {
"Content-Type": [ "application/json" ],
"Content-Length": [ "109" ]
}
},
"Response": {
"StatusCode": 200,
"Headers": {
"Cache-Control": [ "no-cache" ],
"Pragma": [ "no-cache" ],
"X-Content-Type-Options": [ "nosniff" ],
"Strict-Transport-Security": [ "max-age=31536000; includeSubDomains" ],
"Server": [ "Kestrel" ],
"x-ms-ratelimit-remaining-tenant-writes": [ "1199" ],
"x-ms-request-id": [ "746f8be3-9ba4-4323-93fa-3567dff84f3f" ],
"x-ms-correlation-request-id": [ "746f8be3-9ba4-4323-93fa-3567dff84f3f" ],
"x-ms-routing-request-id": [ "EASTUS:20240130T172214Z:746f8be3-9ba4-4323-93fa-3567dff84f3f" ],
"Date": [ "Tue, 30 Jan 2024 17:22:14 GMT" ]
},
"ContentHeaders": {
"Content-Length": [ "22" ],
"Content-Type": [ "application/json; charset=utf-8" ],
"Expires": [ "-1" ]
},
"Content": "{\"nameAvailable\":true}",
"isContentBase64": false
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ if(($null -eq $TestName) -or ($TestName -contains 'Test-AzSupportTicketsNoSubscr
}

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

It 'Check' -skip {
Expand Down
6 changes: 3 additions & 3 deletions src/Support/Support.Autorest/test/env.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"BillingProblemClassificationId": "d0f16bf7-e011-3f3b-1c26-3147f84e0896",
"BillingServiceId": "517f2da6-78fd-0498-4e22-ad26996b1dfc",
"BillingProblemClassificationId": "d0f16bf7-e011-3f3b-1c26-3147f84e0896",
"Tenant": "d71d46f6-114f-4d2a-81c9-8fc86ba8801c",
"FileWorkspaceNameNoSubscription": "test-ps-43ad6585-c0ac-4a13-8d0e-bb633b8b1db3",
"FileWorkspaceNameNoSubscription": "test-ps-94021760-e8a2-4995-85d4-13e6b443eddb",
"SubscriptionId": "4df09db9-7a7e-450b-8f88-00fb97c277bd",
"FileWorkspaceNameSubscription": "test-ps-d4adfb8c-f15c-48de-a0b0-8da419bfe51d"
"FileWorkspaceNameSubscription": "test-ps-515d6c7e-beb8-4617-8325-cfd236c4bc5b"
}
1 change: 1 addition & 0 deletions src/Support/Support.Autorest/test/files/test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test

0 comments on commit f41fe6c

Please sign in to comment.