Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Az. ApplicationInsights] Add testcases for livetest #20943

Merged
merged 2 commits into from
Feb 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions src/ApplicationInsights/LiveTests/TestLiveScenarios.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
Invoke-LiveTestScenario -Name "Create ApplicationInsights" -Description "Test New-AzApplicationInsights" -ScenarioScript `
{
param ($rg)

$rgName = $rg.ResourceGroupName
$appName = New-LiveTestResourceName
$appLocation = "westus"
$appKind = "java"

$actual = New-AzApplicationInsights -Kind $appKind -ResourceGroupName $rgName -Name $appName -location $appLocation
Assert-AreEqual $appName $actual.Name
Assert-AreEqual $appLocation $actual.Location
Assert-AreEqual $appKind $actual.Kind
}

Invoke-LiveTestScenario -Name "List ApplicationInsights" -Description "Test listing ApplicationInsights" -ScenarioScript `
{
param ($rg)

$rgName = $rg.ResourceGroupName
$appName = New-LiveTestResourceName
$appLocation = "westus"
$appKind = "java"

$null = New-AzApplicationInsights -Kind $appKind -ResourceGroupName $rgName -Name $appName -location $appLocation
$actual = Get-AzApplicationInsights -ResourceGroupName $rgName
Assert-AreEqual 1 $actual.Count
}

Invoke-LiveTestScenario -Name "Get ApplicationInsights" -Description "Test getting one ApplicationInsights" -ScenarioScript `
{
param ($rg)

$rgName = $rg.ResourceGroupName
$appName = New-LiveTestResourceName
$appLocation = "westus"
$appKind = "java"

$null = New-AzApplicationInsights -Kind $appKind -ResourceGroupName $rgName -Name $appName -location $appLocation
$actual = Get-AzApplicationInsights -ResourceGroupName $rgName -Name $appName
Assert-AreEqual $appName $actual.Name
}

Invoke-LiveTestScenario -Name "Update ApplicationInsights" -Description "Test Updating one specific ApplicationInsights" -ScenarioScript `
{
param ($rg)

$rgName = $rg.ResourceGroupName
$appName = New-LiveTestResourceName
$appLocation = "westus"
$appKind = "java"

$null = New-AzApplicationInsights -Kind $appKind -ResourceGroupName $rgName -Name $appName -location $appLocation
$null = Update-AzApplicationInsights -ResourceGroupName $rgName -Name $appName -PublicNetworkAccessForIngestion "Disabled"
$actual = Get-AzApplicationInsights -Name $appName -ResourceGroupName $rgName
Assert-AreEqual $actual.PublicNetworkAccessForIngestion "Disabled"
}

Invoke-LiveTestScenario -Name "Remove ApplicationInsights" -Description "Test Removing ApplicationInsights" -ScenarioScript `
{
param ($rg)

$rgName = $rg.ResourceGroupName
$appName = New-LiveTestResourceName
$appLocation = "westus"
$appKind = "java"

$null = New-AzApplicationInsights -Kind $appKind -ResourceGroupName $rgName -Name $appName -location $appLocation
Remove-AzApplicationInsights -ResourceGroupName $rgName -Name $appName
$GetServiceList = Get-AzApplicationInsights -ResourceGroupName $rgName
Assert-False { $GetServiceList.Name -contains $appName}
}