2023-03-07 05:35:51 +03:00
|
|
|
|
BeforeAll {
|
2023-03-18 02:03:45 +03:00
|
|
|
|
Import-Module Az.InfrastructureTesting
|
2023-03-23 23:12:29 +03:00
|
|
|
|
|
|
|
|
|
$Script:rgName = 'rg-test'
|
|
|
|
|
$Script:oiwName = 'oiwName'
|
|
|
|
|
$Script:location = 'westus3'
|
2023-03-07 05:35:51 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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' {
|
2023-03-07 05:35:51 +03:00
|
|
|
|
#arrange
|
2023-03-23 23:12:29 +03:00
|
|
|
|
$params = @{
|
|
|
|
|
ResourceType = "OperationalInsightsWorkspace"
|
|
|
|
|
ResourceGroupName = $rgName
|
|
|
|
|
ResourceName = $oiwName
|
|
|
|
|
}
|
2023-03-07 05:35:51 +03:00
|
|
|
|
|
|
|
|
|
#act
|
2023-03-23 23:12:29 +03:00
|
|
|
|
$result = Confirm-AzBPResource @params
|
2023-03-07 05:35:51 +03:00
|
|
|
|
|
|
|
|
|
#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' {
|
2023-03-07 05:35:51 +03:00
|
|
|
|
#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-07 05:35:51 +03:00
|
|
|
|
|
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" {
|
2023-03-07 05:35:51 +03:00
|
|
|
|
#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-07 05:35:51 +03:00
|
|
|
|
}
|
2023-03-23 23:12:29 +03:00
|
|
|
|
$result = Confirm-AzBPOperationalInsightsWorkspace @params -ErrorAction SilentlyContinue
|
2023-03-07 05:35:51 +03:00
|
|
|
|
|
|
|
|
|
#assert
|
|
|
|
|
$result.Success | Should -Be $false
|
|
|
|
|
}
|
2023-03-09 23:22:04 +03:00
|
|
|
|
|
2023-03-24 22:59:54 +03:00
|
|
|
|
It "Should contain a Operational Insights Workspace named $oiwName" {
|
2023-03-09 23:22:04 +03:00
|
|
|
|
#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" {
|
2023-03-09 23:22:04 +03:00
|
|
|
|
#act
|
|
|
|
|
$result = Confirm-AzBPOperationalInsightsWorkspace -ResourceGroupName $rgName -Name $oiwName
|
|
|
|
|
|
|
|
|
|
#assert
|
2023-03-23 23:12:29 +03:00
|
|
|
|
$result | Should -BeInLocation $location
|
2023-03-09 23:22:04 +03:00
|
|
|
|
}
|
|
|
|
|
|
2023-03-24 22:59:54 +03:00
|
|
|
|
It "Should be a Operational Insights Workspace in a resource group named $rgName" {
|
2023-03-09 23:22:04 +03:00
|
|
|
|
#act
|
|
|
|
|
$result = Confirm-AzBPOperationalInsightsWorkspace -ResourceGroupName $rgName -Name $oiwName
|
|
|
|
|
|
|
|
|
|
#assert
|
2023-03-23 23:12:29 +03:00
|
|
|
|
$result | Should -BeInResourceGroup $rgName
|
2023-03-09 23:22:04 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
2023-03-24 23:52:36 +03:00
|
|
|
|
|
|
|
|
|
AfterAll {
|
2023-03-31 01:40:34 +03:00
|
|
|
|
Get-Module Az.InfrastructureTesting | Remove-Module
|
2023-03-24 23:52:36 +03:00
|
|
|
|
Get-Module BenchPress.Azure | Remove-Module
|
|
|
|
|
}
|