This commit is contained in:
Caroline 2023-04-04 14:21:14 -07:00
Родитель e2dec6e81b
Коммит e19b100252
4 изменённых файлов: 85 добавлений и 8 удалений

Просмотреть файл

@ -381,7 +381,7 @@ function Get-ResourceByType {
return Confirm-WebApp -WebAppName $ResourceName -ResourceGroupName $ResourceGroupName
}
"WebAppStaticSite" {
return Confirm-WebAppStaticSIte -WebAppName $ResourceName -ResourceGroupName $ResourceGroupName
return Confirm-WebAppStaticSIte -StaticWebAppName $ResourceName -ResourceGroupName $ResourceGroupName
}
default {
Write-Information "Not implemented yet"

Просмотреть файл

@ -1,13 +1,13 @@
BeforeAll {
Import-Module Az.InfrastructureTesting
Import-Module ../../bin/BenchPress.Azure.psd1
$Script:rgName = 'rg-test'
$Script:webappName = 'azbpwebapptest'
$Script:location = 'westus3'
}
Describe 'Verify Web App Exists' {
BeforeAll {
$Script:webappName = 'azbpwebapptest'
$Script:noWebAppName = 'noazbpwebapptest'
}
@ -58,6 +58,61 @@ Describe 'Verify Web App Exists' {
}
}
Describe 'Verify Web App Static Site Exists' {
BeforeAll {
$Script:webappStaticSiteName = 'staticwebapptest'
$Script:noWebAppStaticSiteName = 'nostaticwebapptest'
}
It 'Should contain a Web App Static Site with the given name - Confirm-AzBPResource' {
# arrange
$params = @{
ResourceType = "WebAppStaticSite"
ResourceGroupName = $rgName
ResourceName = $webappStaticSiteName
}
# act and assert
Confirm-AzBPResource @params | Should -BeSuccessful
}
It "Should contain a Web App Static Site named $webappStaticSiteName - ConfirmAzBPResource" {
# arrange
$params = @{
ResourceType = "WebAppStaticSite"
ResourceGroupName = $rgName
ResourceName = $webappStaticSiteName
PropertyKey = 'Name'
PropertyValue = $webappStaticSiteName
}
# act and assert
Confirm-AzBPResource @params | Should -BeSuccessful
}
It "Should contain a Web App Static Site named $webappStaticSiteName" {
Confirm-AzBPWebAppStaticSite -ResourceGroupName $rgName -StaticWebAppName $webappStaticSiteName | Should -BeSuccessful
}
It 'Should not contain a Web App Static Site with the given name' {
# The '-ErrorAction SilentlyContinue' command suppresses all errors.
# In this test, it will suppress the error message when a resource cannot be found.
# Remove this field to see all errors.
Confirm-AzBPWebAppStaticSite -ResourceGroupName $rgName -StaticWebAppName $noWebAppStaticSiteName -ErrorAction SilentlyContinue
| Should -Not -BeSuccessful
}
It "Should contain a Web App Static Site named $webappStaticSiteName in $location" {
Confirm-AzBPWebAppStaticSite -ResourceGroupName $rgName -StaticWebAppName $webappStaticSiteName
| Should -BeInLocation $location
}
It "Should be a Web App Static Site in a resource group named $rgName" {
Confirm-AzBPWebAppStaticSite -ResourceGroupName $rgName -StaticWebAppName $webappStaticSiteName
| Should -BeInResourceGroup $rgName
}
}
AfterAll {
Get-Module Az.InfrastructureTesting | Remove-Module
Get-Module BenchPress.Azure | Remove-Module

Просмотреть файл

@ -1,6 +1,7 @@
# How To Run WebApp.Tests.ps1
`WebApp.Tests.ps1` contains examples of using the `Confirm-AzBPWebApp` cmdlet.
`WebApp.Tests.ps1` contains examples of using the `Confirm-AzBPWebApp` and
`Confirm-AzBPWebAppStaticSite` cmdlet.
## Pre-Requisites
@ -23,9 +24,10 @@
1. Update `WebApp.Tests.ps1` variables to point to your expected resources:
- `rg-test` -> `your-resource-group-name`
- `westus3` -> `your-resource-group-location`
- `azbpwebapptest` -> `your-web-app-name`
- `rg-test` -> `your-resource-group-name`
- `westus3` -> `your-resource-group-location`
- `azbpwebapptest` -> `your-web-app-name`
- `staticwebapptest` -> `your-web-app-static-site-name`
1. If using a local copy of `Az.InfrastructureTesting`, replace `Import-Module Az.InfrastructureTesting` with
`Import-Module "../../bin/BenchPress.Azure.psd1"`. Note that the final `AfterAll` step will properly remove the module

Просмотреть файл

@ -1,7 +1,8 @@
param location string = resourceGroup().location
param location string = 'EastUS2'
param appserviceplanName string = 'asp${take(uniqueString(resourceGroup().id), 5)}'
param webappName string = 'webapp${take(uniqueString(resourceGroup().id), 5)}'
param staticwebappName string = 'staticwebapp${take(uniqueString(resourceGroup().id), 5)}'
resource appserviceplan 'Microsoft.Web/serverfarms@2022-03-01' = {
name: appserviceplanName
@ -26,3 +27,22 @@ resource website 'Microsoft.Web/sites@2022-03-01' = {
serverFarmId: appserviceplan.id
}
}
resource staticwebsite 'Microsoft.Web/staticSites@2022-03-01' = {
name: staticwebappName
location: location
tags: {
'hidden-related:${appserviceplan.id}': 'empty'
displayName: 'Website'
}
sku: {
tier: 'Free'
name: 'Free'
}
properties: {
stagingEnvironmentPolicy: 'Enabled'
allowConfigFileUpdates: true
provider: 'None'
enterpriseGradeCdnStatus: 'Disabled'
}
}