forked from dataplat/dbatools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAdd-DbaExtendedProperty.Tests.ps1
37 lines (32 loc) · 1.54 KB
/
Add-DbaExtendedProperty.Tests.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
$CommandName = $MyInvocation.MyCommand.Name.Replace(".Tests.ps1", "")
Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan
. "$PSScriptRoot\constants.ps1"
Describe "$CommandName Unit Tests" -Tag 'UnitTests' {
Context "Validate parameters" {
[array]$params = ([Management.Automation.CommandMetaData]$ExecutionContext.SessionState.InvokeCommand.GetCommand($CommandName, 'Function')).Parameters.Keys
[object[]]$knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'Name', 'InputObject', 'EnableException', 'Value'
It "Should only contain our specific parameters" {
Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params | Should -BeNullOrEmpty
}
}
}
Describe "$CommandName Integration Tests" -Tag "IntegrationTests" {
BeforeAll {
$random = Get-Random
$instance2 = Connect-DbaInstance -SqlInstance $script:instance2
$null = Get-DbaProcess -SqlInstance $instance2 | Where-Object Program -match dbatools | Stop-DbaProcess -Confirm:$false
$newDbName = "dbatoolsci_newdb_$random"
$db = New-DbaDatabase -SqlInstance $instance2 -Name $newDbName
}
AfterAll {
$null = $db | Remove-DbaDatabase -Confirm:$false
}
Context "commands work as expected" {
It "works" {
$ep = $db | Add-DbaExtendedProperty -Name "Test_Database_Name" -Value "Sup"
$ep.Name | Should -Be "Test_Database_Name"
$ep.ParentName | Should -Be $db.Name
$ep.Value | Should -Be "Sup"
}
}
}