Skip to content

Commit e310ad3

Browse files
committed
fix tests
1 parent ff1afb8 commit e310ad3

3 files changed

Lines changed: 19 additions & 19 deletions

File tree

tests/Get-DbaDbDataClassification.Tests.ps1

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Describe $CommandName -Tag IntegrationTests {
3434
$random = Get-Random
3535
$dbName = "dbatoolsci_dataclass_$random"
3636
$tableName = "dbatoolsci_table_$random"
37-
$db = New-DbaDatabase -SqlInstance $TestConfig.instance2 -Name $dbName
37+
$db = New-DbaDatabase -SqlInstance $TestConfig.SingleInstance -Name $dbName
3838

3939
# Create a test table with columns to classify
4040
$db.Query("CREATE TABLE dbo.$tableName (Id INT, EmailAddress NVARCHAR(255), CreditCardNumber NVARCHAR(20))")
@@ -53,40 +53,40 @@ Describe $CommandName -Tag IntegrationTests {
5353
# We want to run all commands in the AfterAll block with EnableException to ensure that the test fails if the cleanup fails.
5454
$PSDefaultParameterValues["*-Dba*:EnableException"] = $true
5555

56-
$null = Remove-DbaDatabase -SqlInstance $TestConfig.instance2 -Database $dbName -Confirm:$false
56+
$null = Remove-DbaDatabase -SqlInstance $TestConfig.SingleInstance -Database $dbName -Confirm:$false
5757

5858
$PSDefaultParameterValues.Remove("*-Dba*:EnableException")
5959
}
6060

6161
Context "commands work as expected" {
6262

6363
It "finds classifications in a database" {
64-
$result = Get-DbaDbDataClassification -SqlInstance $TestConfig.instance2 -Database $dbName
64+
$result = Get-DbaDbDataClassification -SqlInstance $TestConfig.SingleInstance -Database $dbName
6565
$result | Should -Not -BeNullOrEmpty
6666
$result.Count | Should -Be 1
6767
}
6868

6969
It "returns correct classification details" {
70-
$result = Get-DbaDbDataClassification -SqlInstance $TestConfig.instance2 -Database $dbName
70+
$result = Get-DbaDbDataClassification -SqlInstance $TestConfig.SingleInstance -Database $dbName
7171
$result.Table | Should -Be $tableName
7272
$result.Column | Should -Be "EmailAddress"
7373
$result.InformationType | Should -Be "Contact Info"
7474
$result.SensitivityLabel | Should -Be "Confidential"
7575
}
7676

7777
It "filters by table" {
78-
$result = Get-DbaDbDataClassification -SqlInstance $TestConfig.instance2 -Database $dbName -Table $tableName
78+
$result = Get-DbaDbDataClassification -SqlInstance $TestConfig.SingleInstance -Database $dbName -Table $tableName
7979
$result | Should -Not -BeNullOrEmpty
8080
}
8181

8282
It "filters by column" {
83-
$result = Get-DbaDbDataClassification -SqlInstance $TestConfig.instance2 -Database $dbName -Column "EmailAddress"
83+
$result = Get-DbaDbDataClassification -SqlInstance $TestConfig.SingleInstance -Database $dbName -Column "EmailAddress"
8484
$result | Should -Not -BeNullOrEmpty
8585
$result.Column | Should -Be "EmailAddress"
8686
}
8787

8888
It "returns nothing for unclassified column filter" {
89-
$result = Get-DbaDbDataClassification -SqlInstance $TestConfig.instance2 -Database $dbName -Column "CreditCardNumber"
89+
$result = Get-DbaDbDataClassification -SqlInstance $TestConfig.SingleInstance -Database $dbName -Column "CreditCardNumber"
9090
$result | Should -BeNullOrEmpty
9191
}
9292

tests/Remove-DbaDbDataClassification.Tests.ps1

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Describe $CommandName -Tag IntegrationTests {
2828
$random = Get-Random
2929
$dbName = "dbatoolsci_removedataclass_$random"
3030
$tableName = "dbatoolsci_table_$random"
31-
$db = New-DbaDatabase -SqlInstance $TestConfig.instance2 -Name $dbName
31+
$db = New-DbaDatabase -SqlInstance $TestConfig.SingleInstance -Name $dbName
3232

3333
# Create a test table
3434
$db.Query("CREATE TABLE dbo.$tableName (Id INT, Email NVARCHAR(255), Phone NVARCHAR(20))")
@@ -49,31 +49,31 @@ Describe $CommandName -Tag IntegrationTests {
4949
# We want to run all commands in the AfterAll block with EnableException to ensure that the test fails if the cleanup fails.
5050
$PSDefaultParameterValues["*-Dba*:EnableException"] = $true
5151

52-
$null = Remove-DbaDatabase -SqlInstance $TestConfig.instance2 -Database $dbName -Confirm:$false
52+
$null = Remove-DbaDatabase -SqlInstance $TestConfig.SingleInstance -Database $dbName -Confirm:$false
5353

5454
$PSDefaultParameterValues.Remove("*-Dba*:EnableException")
5555
}
5656

5757
Context "commands work as expected" {
5858

5959
It "removes a classification from a column" {
60-
$classification = Get-DbaDbDataClassification -SqlInstance $TestConfig.instance2 -Database $dbName -Column "Email"
60+
$classification = Get-DbaDbDataClassification -SqlInstance $TestConfig.SingleInstance -Database $dbName -Column "Email"
6161
$classification | Should -Not -BeNullOrEmpty
6262

6363
$result = $classification | Remove-DbaDbDataClassification -Confirm:$false
6464
$result.Status | Should -Be "Removed"
6565

66-
$afterRemove = Get-DbaDbDataClassification -SqlInstance $TestConfig.instance2 -Database $dbName -Column "Email"
66+
$afterRemove = Get-DbaDbDataClassification -SqlInstance $TestConfig.SingleInstance -Database $dbName -Column "Email"
6767
$afterRemove | Should -BeNullOrEmpty
6868
}
6969

7070
It "removes all classifications when piping all results" {
71-
$before = Get-DbaDbDataClassification -SqlInstance $TestConfig.instance2 -Database $dbName
71+
$before = Get-DbaDbDataClassification -SqlInstance $TestConfig.SingleInstance -Database $dbName
7272
$before | Should -Not -BeNullOrEmpty
7373

7474
$before | Remove-DbaDbDataClassification -Confirm:$false
7575

76-
$after = Get-DbaDbDataClassification -SqlInstance $TestConfig.instance2 -Database $dbName
76+
$after = Get-DbaDbDataClassification -SqlInstance $TestConfig.SingleInstance -Database $dbName
7777
$after | Should -BeNullOrEmpty
7878
}
7979
}

tests/Set-DbaDbDataClassification.Tests.ps1

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Describe $CommandName -Tag IntegrationTests {
3838
$random = Get-Random
3939
$dbName = "dbatoolsci_setdataclass_$random"
4040
$tableName = "dbatoolsci_table_$random"
41-
$db = New-DbaDatabase -SqlInstance $TestConfig.instance2 -Name $dbName
41+
$db = New-DbaDatabase -SqlInstance $TestConfig.InstanceSingle -Name $dbName
4242

4343
# Create a test table with columns
4444
$db.Query("CREATE TABLE dbo.$tableName (Id INT, Email NVARCHAR(255), SSN NVARCHAR(20))")
@@ -51,7 +51,7 @@ Describe $CommandName -Tag IntegrationTests {
5151
# We want to run all commands in the AfterAll block with EnableException to ensure that the test fails if the cleanup fails.
5252
$PSDefaultParameterValues["*-Dba*:EnableException"] = $true
5353

54-
$null = Remove-DbaDatabase -SqlInstance $TestConfig.instance2 -Database $dbName -Confirm:$false
54+
$null = Remove-DbaDatabase -SqlInstance $TestConfig.InstanceSingle -Database $dbName -Confirm:$false
5555

5656
$PSDefaultParameterValues.Remove("*-Dba*:EnableException")
5757
}
@@ -60,7 +60,7 @@ Describe $CommandName -Tag IntegrationTests {
6060

6161
It "sets a classification with known information type and sensitivity label" {
6262
$splatSet = @{
63-
SqlInstance = $TestConfig.instance2
63+
SqlInstance = $TestConfig.InstanceSingle
6464
Database = $dbName
6565
Table = $tableName
6666
Column = "Email"
@@ -78,7 +78,7 @@ Describe $CommandName -Tag IntegrationTests {
7878

7979
It "updates an existing classification" {
8080
$splatUpdate = @{
81-
SqlInstance = $TestConfig.instance2
81+
SqlInstance = $TestConfig.InstanceSingle
8282
Database = $dbName
8383
Table = $tableName
8484
Column = "Email"
@@ -92,7 +92,7 @@ Describe $CommandName -Tag IntegrationTests {
9292

9393
It "supports piping from Get-DbaDbDataClassification" {
9494
$splatGet = @{
95-
SqlInstance = $TestConfig.instance2
95+
SqlInstance = $TestConfig.InstanceSingle
9696
Database = $dbName
9797
Column = "Email"
9898
}
@@ -102,7 +102,7 @@ Describe $CommandName -Tag IntegrationTests {
102102

103103
It "sets classification with custom information type and explicit GUID" {
104104
$splatCustom = @{
105-
SqlInstance = $TestConfig.instance2
105+
SqlInstance = $TestConfig.InstanceSingle
106106
Database = $dbName
107107
Table = $tableName
108108
Column = "SSN"

0 commit comments

Comments
 (0)