forked from dataplat/dbatools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFind-DbaSimilarTable.Tests.ps1
29 lines (25 loc) · 1.25 KB
/
Find-DbaSimilarTable.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
$commandname = $MyInvocation.MyCommand.Name.Replace(".Tests.ps1", "")
Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan
. "$PSScriptRoot\constants.ps1"
Describe "$commandname Integration Tests" -Tags "IntegrationTests" {
Context "Testing if similar tables are discovered" {
BeforeAll {
$db = Get-DbaDatabase -SqlInstance $script:instance1 -Database tempdb
$db.Query("CREATE TABLE dbatoolsci_table1 (id int identity, fname varchar(20), lname char(5), lol bigint, whatever datetime)")
$db.Query("CREATE TABLE dbatoolsci_table2 (id int identity, fname varchar(20), lname char(5), lol bigint, whatever datetime)")
}
AfterAll {
$db.Query("DROP TABLE dbatoolsci_table1")
$db.Query("DROP TABLE dbatoolsci_table2")
}
$results = Find-DbaSimilarTable -SqlInstance $script:instance1 -Database tempdb | Where-Object Table -Match dbatoolsci
It "returns at least two rows" { # not an exact count because who knows
$results.Count -ge 2 | Should Be $true
}
foreach ($result in $results) {
It "matches 100% for the test tables" {
$result.MatchPercent -eq 100 | Should Be $true
}
}
}
}