benchpress/examples/OperationalInsightsWorkspace/OperationalInsightsWorkspac...

99 строки
2.6 KiB
PowerShell
Исходник Обычный вид История

BeforeAll {
Import-Module Az.InfrastructureTesting
2023-03-23 23:12:29 +03:00
$Script:rgName = 'rg-test'
$Script:oiwName = 'oiwName'
$Script:location = 'westus3'
}
Describe 'Verify Operational Insights Workspace Exists' {
2023-03-23 23:12:29 +03:00
BeforeAll {
2023-03-24 23:47:58 +03:00
$Script:noOiwName = 'noOiwName'
2023-03-23 23:12:29 +03:00
}
2023-03-24 22:59:54 +03:00
It 'Should contain a Operational Insights Workspace with given name - Confirm-AzBPResource' {
#arrange
2023-03-23 23:12:29 +03:00
$params = @{
ResourceType = "OperationalInsightsWorkspace"
ResourceGroupName = $rgName
ResourceName = $oiwName
}
#act
2023-03-23 23:12:29 +03:00
$result = Confirm-AzBPResource @params
#assert
$result.Success | Should -Be $true
}
2023-03-23 23:12:29 +03:00
2023-03-24 22:59:54 +03:00
It 'Should contain a Operational Insights Workspace with expected property name - Confirm-AzBPResource' {
#arrange
2023-03-23 23:12:29 +03:00
$params = @{
ResourceType = "OperationalInsightsWorkspace"
ResourceGroupName = $rgName
ResourceName = $oiwName
PropertyKey = 'Name'
PropertyValue = $oiwName
}
#act
$result = Confirm-AzBPResource @params
#assert
$result.Success | Should -Be $true
}
2023-03-24 22:59:54 +03:00
It "Should contain a Operational Insights Workspace named $oiwName" {
2023-03-23 23:12:29 +03:00
#act
$result = Confirm-AzBPOperationalInsightsWorkspace -ResourceGroupName $rgName -Name $oiwName
#assert
$result.Success | Should -Be $true
}
2023-03-24 23:47:58 +03:00
It "Should not contain an Operational Insights Workspace named $noOiwName" {
#act
# 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.
$params = @{
ResourceGroupName = $rgName
2023-03-24 23:47:58 +03:00
Name = $noOiwName
}
2023-03-23 23:12:29 +03:00
$result = Confirm-AzBPOperationalInsightsWorkspace @params -ErrorAction SilentlyContinue
#assert
$result.Success | Should -Be $false
}
2023-03-24 22:59:54 +03:00
It "Should contain a Operational Insights Workspace named $oiwName" {
#act
$result = Confirm-AzBPOperationalInsightsWorkspace -ResourceGroupName $rgName -Name $oiwName
#assert
$result | Should -BeDeployed
}
2023-03-24 22:59:54 +03:00
It "Should contain a Operational Insights Workspace named $oiwName in $location" {
#act
$result = Confirm-AzBPOperationalInsightsWorkspace -ResourceGroupName $rgName -Name $oiwName
#assert
2023-03-23 23:12:29 +03:00
$result | Should -BeInLocation $location
}
2023-03-24 22:59:54 +03:00
It "Should be a Operational Insights Workspace in a resource group named $rgName" {
#act
$result = Confirm-AzBPOperationalInsightsWorkspace -ResourceGroupName $rgName -Name $oiwName
#assert
2023-03-23 23:12:29 +03:00
$result | Should -BeInResourceGroup $rgName
}
}
2023-03-24 23:52:36 +03:00
AfterAll {
Get-Module Az.InfrastructureTesting | Remove-Module
2023-03-24 23:52:36 +03:00
Get-Module BenchPress.Azure | Remove-Module
}