Skip to content

Commit

Permalink
changes to not create new resources in playback
Browse files Browse the repository at this point in the history
  • Loading branch information
grhuangmsft committed Mar 7, 2024
1 parent eec230e commit 7643b1c
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 24 deletions.
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"New-AzSupportFileWorkspacesNoSubscription+[NoContext]+Create+$PUT+https://management.azure.com/providers/Microsoft.Support/fileWorkspaces/test-ps-a169629b-d263-4ba1-872a-0d79019ca2d3?api-version=2022-09-01-preview+1": {
"New-AzSupportFileWorkspacesNoSubscription+[NoContext]+Create+$PUT+https://management.azure.com/providers/Microsoft.Support/fileWorkspaces/test-ps-5ebdcaf4-0742-4dfd-9e49-73e13b88283e?api-version=2022-09-01-preview+1": {
"Request": {
"Method": "PUT",
"RequestUri": "https://management.azure.com/providers/Microsoft.Support/fileWorkspaces/test-ps-a169629b-d263-4ba1-872a-0d79019ca2d3?api-version=2022-09-01-preview",
"RequestUri": "https://management.azure.com/providers/Microsoft.Support/fileWorkspaces/test-ps-5ebdcaf4-0742-4dfd-9e49-73e13b88283e?api-version=2022-09-01-preview",
"Content": null,
"isContentBase64": false,
"Headers": {
"x-ms-unique-id": [ "1" ],
"x-ms-client-request-id": [ "6003c6f3-0370-42db-9fb6-2e20da8b2a7b" ],
"x-ms-unique-id": [ "10" ],
"x-ms-client-request-id": [ "3e831bb8-b203-46a3-a841-dbb8481273fe" ],
"CommandName": [ "New-AzSupportFileWorkspacesNoSubscription" ],
"FullCommandName": [ "New-AzSupportFileWorkspacesNoSubscription_Create" ],
"ParameterSetName": [ "__AllParameterSets" ],
"User-Agent": [ "AzurePowershell/v11.2.0", "PSVersion/v7.3.11", "Az.Support/0.1.0" ],
"User-Agent": [ "AzurePowershell/v11.2.0", "PSVersion/v7.4.1", "Az.Support/0.1.0" ],
"Authorization": [ "[Filtered]" ]
},
"ContentHeaders": {
Expand All @@ -22,22 +22,23 @@
"Headers": {
"Cache-Control": [ "no-cache" ],
"Pragma": [ "no-cache" ],
"Location": [ "https://management.azure.com/providers/Microsoft.Support/fileWorkspaces/test-ps-a169629b-d263-4ba1-872a-0d79019ca2d3?api-version=2022-09-01-preview" ],
"Location": [ "https://management.azure.com/providers/Microsoft.Support/fileWorkspaces/test-ps-5ebdcaf4-0742-4dfd-9e49-73e13b88283e?api-version=2022-09-01-preview" ],
"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": [ "14af729f-4c8b-487d-a086-58b16d9d19f8" ],
"x-ms-correlation-request-id": [ "14af729f-4c8b-487d-a086-58b16d9d19f8" ],
"x-ms-routing-request-id": [ "EASTUS:20240129T212541Z:14af729f-4c8b-487d-a086-58b16d9d19f8" ],
"Date": [ "Mon, 29 Jan 2024 21:25:40 GMT" ]
"x-ms-request-id": [ "982c5b6f-47ed-4933-a0d6-ff4260e462e5" ],
"x-ms-correlation-request-id": [ "982c5b6f-47ed-4933-a0d6-ff4260e462e5" ],
"x-ms-routing-request-id": [ "EASTUS2:20240307T190932Z:982c5b6f-47ed-4933-a0d6-ff4260e462e5" ],
"X-Cache": [ "CONFIG_NOCACHE" ],
"X-MSEdge-Ref": [ "Ref A: 25702B615D874BAAAB6D194868D0922F Ref B: BL2AA2010205017 Ref C: 2024-03-07T19:09:31Z" ],
"Date": [ "Thu, 07 Mar 2024 19:09:32 GMT" ]
},
"ContentHeaders": {
"Content-Length": [ "283" ],
"Content-Type": [ "application/json; charset=utf-8" ],
"Expires": [ "-1" ]
},
"Content": "{\"id\":\"/providers/Microsoft.Support/fileWorkspaces/test-ps-a169629b-d263-4ba1-872a-0d79019ca2d3\",\"name\":\"test-ps-a169629b-d263-4ba1-872a-0d79019ca2d3\",\"type\":\"Microsoft.Support/fileWorkspaces\",\"properties\":{\"expirationTime\":\"2024-01-30T21:25:41Z\",\"createdOn\":\"2024-01-29T21:25:41Z\"}}",
"Content": "{\"id\":\"/providers/Microsoft.Support/fileWorkspaces/test-ps-5ebdcaf4-0742-4dfd-9e49-73e13b88283e\",\"name\":\"test-ps-5ebdcaf4-0742-4dfd-9e49-73e13b88283e\",\"type\":\"Microsoft.Support/fileWorkspaces\",\"properties\":{\"expirationTime\":\"2024-03-08T19:09:32Z\",\"createdOn\":\"2024-03-07T19:09:32Z\"}}",
"isContentBase64": false
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ if(($null -eq $TestName) -or ($TestName -contains 'New-AzSupportFileWorkspacesNo

Describe 'New-AzSupportFileWorkspacesNoSubscription' {
It 'Create' {
$fileWorkspaceName = "test-ps-$(New-Guid)"
$fileWorkspaceName = $env.fileWorkspaceNameNoSubscription2
$fileWorkspace = New-AzSupportFileWorkspacesNoSubscription -Name $fileWorkspaceName
$fileWorkspace.Name | Should -Be $fileWorkspaceName
}
Expand Down
35 changes: 24 additions & 11 deletions src/Support/Support.Autorest/test/utils.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,29 @@ function setupEnv() {
$testGuid = [guid]::NewGuid().ToString()
$env.BillingServiceId = "517f2da6-78fd-0498-4e22-ad26996b1dfc"
$env.BillingProblemClassificationId = "d0f16bf7-e011-3f3b-1c26-3147f84e0896"
$env.FileWorkspaceNameSubscription = "test-ps-$(New-Guid)"
$env.FileWorkspaceNameNoSubscription = "test-ps-$(New-Guid)"
$fileWorkspaceNameSubscription = "test-ps-$(New-Guid)"
$fileWorkspaceNameNoSubscription = "test-ps-$(New-Guid)"
$fileWorkspaceNameSubscription2 = "test-ps-$(New-Guid)"
$fileWorkspaceNameNoSubscription2 = "test-ps-$(New-Guid)"
$env.AddWithCache("FileWorkspaceNameSubscription", $fileWorkspaceNameSubscription, $UsePreviousConfigForRecord)
$env.AddWithCache("FileWorkspaceNameNoSubscription", $fileWorkspaceNameNoSubscription, $UsePreviousConfigForRecord)
$env.AddWithCache("FileWorkspaceNameSubscription2", $fileWorkspaceNameSubscription2, $UsePreviousConfigForRecord)
$env.AddWithCache("FileWorkspaceNameNoSubscription2", $fileWorkspaceNameNoSubscription2, $UsePreviousConfigForRecord)
# $env.FileWorkspaceNameSubscription = "test-ps-$(New-Guid)"
# $env.FileWorkspaceNameNoSubscription = "test-ps-$(New-Guid)"

$testFilePath = Join-Path $PSScriptRoot files test2.txt
if($env.HasSubscription){
New-AzSupportFileWorkspace -Name $env.FileWorkspaceNameSubscription
New-AzSupportFileAndUpload -WorkspaceName $env.FileWorkspaceNameSubscription -FilePath $testFilePath
}
else{
New-AzSupportFileWorkspacesNoSubscription -Name $env.FileWorkspaceNameNoSubscription
New-AzSupportFileAndUploadNoSubscription -WorkspaceName $env.FileWorkspaceNameNoSubscription -FilePath $testFilePath
if($TestMode -ne 'playback'){
if($env.HasSubscription){
New-AzSupportFileWorkspace -Name $env.FileWorkspaceNameSubscription
New-AzSupportFileAndUpload -WorkspaceName $env.FileWorkspaceNameSubscription -FilePath $testFilePath
}
else{
New-AzSupportFileWorkspacesNoSubscription -Name $env.FileWorkspaceNameNoSubscription
New-AzSupportFileAndUploadNoSubscription -WorkspaceName $env.FileWorkspaceNameNoSubscription -FilePath $testFilePath
}
}


$testTicketName = "test-$testGuid"
$advancedDiagnosticConsent = "no"
Expand Down Expand Up @@ -111,8 +122,8 @@ function setupEnv() {
$env.AddWithCache("Sender", $msgSender, $UsePreviousConfigForRecord)
$env.AddWithCache("Subject", $subject, $UsePreviousConfigForRecord)
$env.AddWithCache("Body", $body, $UsePreviousConfigForRecord)

if($env.HasSubscription){
if($TestMode -ne 'playback'){
if($env.HasSubscription){
write-host "creating a support ticket request at subscription level"
$supportTicketSubscription = New-AzSupportTicket -Name $env.Name -AdvancedDiagnosticConsent $env.AdvancedDiagnosticConsent -ContactDetailCountry $env.ContactDetailCountry -ContactDetailFirstName $env.ContactDetailFirstName -ContactDetailLastName $env.ContactDetailLastName -ContactDetailPreferredContactMethod $env.ContactDetailPreferredContactMethod -ContactDetailPreferredSupportLanguage $env.ContactDetailPreferredSupportLanguage -ContactDetailPreferredTimeZone $env.ContactDetailPreferredTimeZone -ContactDetailPrimaryEmailAddress $env.ContactDetailPrimaryEmailAddress -Description $env.Description -ProblemClassificationId $env.ProblemClassificationId -ServiceId $env.ServiceId -Severity $env.Severity -Title $env.Title
write-host "adding a message at subscription level"
Expand All @@ -136,6 +147,8 @@ function setupEnv() {
# }
$env.AddWithCache("SupportPlanTenant", $supportTicketTenant.SupportPlanDisplayName.ToString(), $UsePreviousConfigForRecord)
}
}



# For any resources you created for test, you should add it to $env here.
Expand Down

0 comments on commit 7643b1c

Please sign in to comment.