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

Update tests to be able to run them outside of AppVeyor (part 3) #9426

Merged
merged 31 commits into from
Oct 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
4ad3ee8
some more fixes
andreasjordan Jul 20, 2024
b8d71c5
fix test
andreasjordan Jul 20, 2024
338c203
more fixes
andreasjordan Jul 21, 2024
e5acd20
more fixes
andreasjordan Jul 21, 2024
e905510
more fixes
andreasjordan Jul 21, 2024
886e639
more fixes
andreasjordan Jul 21, 2024
b6a4cac
more fixes
andreasjordan Jul 21, 2024
379690e
more fixes
andreasjordan Jul 21, 2024
7b292ac
disable failing tests
andreasjordan Jul 21, 2024
14e8892
more fixes
andreasjordan Jul 22, 2024
74be105
more fixes
andreasjordan Jul 22, 2024
7926fff
fix test (do Start-DbaXESession)
andreasjordan Jul 22, 2024
936d776
skip test on appvayor
andreasjordan Jul 22, 2024
e7ff850
revert changes
andreasjordan Jul 22, 2024
bc506b1
revert changes
andreasjordan Jul 22, 2024
9b5ae5b
revert changes
andreasjordan Jul 22, 2024
8a712b5
revert changes
andreasjordan Jul 22, 2024
397c044
revert changes
andreasjordan Jul 22, 2024
fa98381
revert part of the test (do Find-DbaAgentJob)
andreasjordan Jul 24, 2024
944c9cf
just use one command
andreasjordan Jul 26, 2024
142d16e
revert the changes
andreasjordan Jul 26, 2024
ac21c00
just to trigger build (do Find)
niphlod Jul 30, 2024
ee9a982
reorg context (do Find)
niphlod Jul 30, 2024
cdb9eec
something is funny either with the before or after steps (do Find-Dba…
niphlod Jul 30, 2024
5cfe287
comment out more (do Find-DbaAgent)
niphlod Jul 30, 2024
b8d137c
investigating service status (do Find-DbaAgent)
niphlod Jul 30, 2024
82c6434
trying to remove the offending job that can't be started (do Find-Dba…
niphlod Jul 30, 2024
893d92a
another kind of setup (do Find-DbaAgent)
niphlod Jul 30, 2024
3e5dbb5
start job outside of the beforeall (do Find-DbaAgent)
niphlod Jul 30, 2024
eaa1099
retrieve real name for jobstep (do Find)
niphlod Jul 30, 2024
192633f
Merge branch 'development' into test_refactoring_3
potatoqualitee Sep 18, 2024
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
3 changes: 3 additions & 0 deletions tests/Add-DbaDbMirrorMonitor.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ Describe "$commandname Integration Tests" -Tag "IntegrationTests" {
BeforeAll {
$null = Remove-DbaDbMirrorMonitor -SqlInstance $script:instance2 -WarningAction SilentlyContinue
}
AfterAll {
$null = Remove-DbaDbMirrorMonitor -SqlInstance $script:instance2 -WarningAction SilentlyContinue
}

It "adds the mirror monitor" {
$results = Add-DbaDbMirrorMonitor -SqlInstance $script:instance2 -WarningAction SilentlyContinue
Expand Down
11 changes: 7 additions & 4 deletions tests/Copy-DbaAgentJob.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,16 @@ Describe "$commandname Integration Tests" -Tag "IntegrationTests" {
$destjobs = Get-DbaAgentJob -SqlInstance $script:instance3
}
AfterAll {
$null = Remove-DbaAgentJob -SqlInstance $script:instance2, $script:instance3 -Job dbatoolsci_copyjob, dbatoolsci_copyjob_disabled -Confirm:$false
$null = Remove-DbaAgentJob -SqlInstance $script:instance2 -Job dbatoolsci_copyjob, dbatoolsci_copyjob_disabled -Confirm:$false
$null = Remove-DbaAgentJob -SqlInstance $script:instance3 -Job dbatoolsci_copyjob, dbatoolsci_copyjob_disabled -Confirm:$false
}

Context "Command copies jobs properly" {
$results = Copy-DbaAgentJob -Source $script:instance2 -Destination $script:instance3 -Job dbatoolsci_copyjob

It "returns one success" {
$results.Name -eq "dbatoolsci_copyjob"
$results.Status -eq "Successful"
$results.Name | Should -Be "dbatoolsci_copyjob"
$results.Status | Should -Be "Successful"
}

It "did not copy dbatoolsci_copyjob_disabled" {
Expand All @@ -38,7 +39,9 @@ Describe "$commandname Integration Tests" -Tag "IntegrationTests" {

It "disables jobs when requested" {
(Get-DbaAgentJob -SqlInstance $script:instance2 -Job dbatoolsci_copyjob_disabled).Enabled
$results = Copy-DbaAgentJob -Source $script:instance2 -Destination $script:instance3 -Job dbatoolsci_copyjob_disabled -DisableOnSource -DisableOnDestination
$results = Copy-DbaAgentJob -Source $script:instance2 -Destination $script:instance3 -Job dbatoolsci_copyjob_disabled -DisableOnSource -DisableOnDestination -Force
$results.Name | Should -Be "dbatoolsci_copyjob_disabled"
$results.Status | Should -Be "Successful"
(Get-DbaAgentJob -SqlInstance $script:instance2 -Job dbatoolsci_copyjob_disabled).Enabled | Should -Be $false
(Get-DbaAgentJob -SqlInstance $script:instance3 -Job dbatoolsci_copyjob_disabled).Enabled | Should -Be $false
}
Expand Down
1 change: 1 addition & 0 deletions tests/Copy-DbaBackupDevice.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ if (-not $env:appveyor) {
} catch {
# don't care
}
Get-ChildItem -Path $backupfilename | Remove-Item
}

$results = Copy-DbaBackupDevice -Source $script:instance1 -Destination $script:instance2 -WarningVariable warn -WarningAction SilentlyContinue 3> $null
Expand Down
3 changes: 3 additions & 0 deletions tests/Copy-DbaDatabase.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ Describe "$commandname Integration Tests" -Tag "IntegrationTests" {
$results[0].DestinationDatabase | Should -Be $newname
$files = Get-DbaDbFile -Sqlinstance $script:instance3 -Database $newname
($files.PhysicalName -like "*$newname*").count | Should -Be $files.count
$null = Remove-DbaDatabase -SqlInstance $script:instance3 -Database $newname
}

It "Should prefix databasename and files" {
Expand All @@ -214,12 +215,14 @@ Describe "$commandname Integration Tests" -Tag "IntegrationTests" {
$results[0].DestinationDatabase | Should -Be "$prefix$backuprestoredb"
$files = Get-DbaDbFile -Sqlinstance $script:instance3 -Database "$prefix$backuprestoredb"
($files.PhysicalName -like "*$prefix$backuprestoredb*").count | Should -Be $files.count
$null = Remove-DbaDatabase -SqlInstance $script:instance3 -Database "$prefix$backuprestoredb"
}

$null = Restore-DbaDatabase -SqlInstance $script:instance2 -path $script:appveyorlabrepo\RestoreTimeClean2016 -useDestinationDefaultDirectories
It "Should warn and exit if newname and >1 db specified" {
$null = Copy-DbaDatabase -Source $script:instance2 -Destination $script:instance3 -Database $backuprestoredb, RestoreTimeClean -DetachAttach -Reattach -NewName warn -WarningVariable warnvar 3> $null
$warnvar | Should -BeLike "*Cannot use NewName when copying multiple databases"
$null = Remove-DbaDatabase -SqlInstance $script:instance2 -Database RestoreTimeClean
}
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Export-DbaBinaryFile.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Describe "$commandname Integration Tests" -Tags "IntegrationTests" {
BeforeEach {
$db = Get-DbaDatabase -SqlInstance $script:instance2 -Database tempdb
$null = $db.Query("CREATE TABLE [dbo].[BunchOFilezz]([FileName123] [nvarchar](50) NULL, [TheFile123] [image] NULL)")
$null = Import-DbaBinaryFile -SqlInstance $script:instance2 -Database tempdb -Table BunchOFilezz -FilePath $script:appveyorlabrepo\azure\adalsql.msi -Verbose
$null = Import-DbaBinaryFile -SqlInstance $script:instance2 -Database tempdb -Table BunchOFilezz -FilePath $script:appveyorlabrepo\azure\adalsql.msi
$null = Get-ChildItem $script:appveyorlabrepo\certificates | Import-DbaBinaryFile -SqlInstance $script:instance2 -Database tempdb -Table BunchOFilezz
}
AfterEach {
Expand Down
5 changes: 4 additions & 1 deletion tests/Export-DbaXESessionTemplate.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@ Describe "$CommandName Unit Tests" -Tag 'UnitTests' {
}

Describe "$CommandName Integration Tests" -Tags "IntegrationTests" {
BeforeAll {
$null = Get-DbaXESession -SqlInstance $script:instance2 -Session 'Profiler TSQL Duration' | Remove-DbaXESession
}
AfterAll {
$null = Get-DbaXESession -SqlInstance $script:instance2 -Session db_ola_health | Remove-DbaXESession
$null = Get-DbaXESession -SqlInstance $script:instance2 -Session 'Profiler TSQL Duration' | Remove-DbaXESession
Remove-Item -Path 'C:\windows\temp\Profiler TSQL Duration.xml' -ErrorAction SilentlyContinue
}
Context "Test Importing Session Template" {
Expand Down
42 changes: 26 additions & 16 deletions tests/Find-DbaAgentJob.Tests.ps1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the change from 13 to 2 is the only thing that I can't readily say "ok, I get it"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me change that back and see what happens...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests are still green. How is that possible?

Maybe because the test failed with an exception:
image

So we don't catch those errors, or am I missing something?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you look at the AppVayor output from the dbatools-buildref-index.json run, you see more failed tests.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup, it seems that those tests have a structure that is not compatible with pester.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But the test works locally on my maschine.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

problem here is that something either on the beforeall or afterall raises an error (seemingly the offending one is Start-DbaAgentJob -SqlInstance $script:instance2 -Job 'dbatoolsci_testjob').
I'm trying different variations because here, e.g., it seems that there are a sleuth of other jobs already present due to other tests (and the reason why the test creates 2 jobs but checks for 11, which is strange).
Being "bad-dy" ideally this test should clear out any existing job on the agent, create its own, do the tests, and re-cleanup (optionally).
Approaching with a bit of brain, the test creates two jobs and may only make assumptions on those two (and doing so, if one wants to run it locally, it will try - at least - to preserve already existing jobs).
I fear that starting the job (which is the step failing in the beforeall, and avoiding all the tests to be run) is needed for the very last test, but, still, I'm investigating.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aaaand found. jobstep was failing to be created, because appveyor targets "localhost\SQL2016" but the param -SubsystemServer needs the real name (doesn't work with "localhost"). JobStep was failing to be created silently, Start-DbaAgent excepted (because it was a job with no steps), Pester4 doesn't handle well exceptions in the beforeall/afterall blocks.

Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,28 @@ Describe "$CommandName Unit Tests" -Tag 'UnitTests' {
}
}

Describe "$commandname Integration Tests" -Tags "IntegrationTests" {
BeforeAll {
$null = New-DbaAgentJob -SqlInstance $script:instance2 -Job 'dbatoolsci_testjob' -OwnerLogin 'sa'
$null = New-DbaAgentJobStep -SqlInstance $script:instance2 -Job 'dbatoolsci_testjob' -StepId 1 -StepName 'dbatoolsci Failed' -Subsystem TransactSql -SubsystemServer $script:instance2 -Command "RAISERROR (15600,-1,-1, 'dbatools_error');" -CmdExecSuccessCode 0 -OnSuccessAction QuitWithSuccess -OnFailAction QuitWithFailure -Database master -DatabaseUser sa -RetryAttempts 1 -RetryInterval 2
$null = Start-DbaAgentJob -SqlInstance $script:instance2 -Job 'dbatoolsci_testjob'
$null = New-DbaAgentJobCategory -SqlInstance $script:instance2 -Category 'dbatoolsci_job_category' -CategoryType LocalJob
$null = New-DbaAgentJob -SqlInstance $script:instance2 -Job 'dbatoolsci_testjob_disabled' -Category 'dbatoolsci_job_category' -Disabled
$null = New-DbaAgentJobStep -SqlInstance $script:instance2 -Job 'dbatoolsci_testjob_disabled' -StepId 1 -StepName 'dbatoolsci Test Step' -Subsystem TransactSql -SubsystemServer $script:instance2 -Command 'SELECT * FROM master.sys.all_columns' -CmdExecSuccessCode 0 -OnSuccessAction QuitWithSuccess -OnFailAction QuitWithFailure -Database master -DatabaseUser sa -RetryAttempts 1 -RetryInterval 2
}
AfterAll {
$null = Remove-DbaAgentJob -SqlInstance $script:instance2 -Job dbatoolsci_testjob, dbatoolsci_testjob_disabled -Confirm:$false
$null = Remove-DbaAgentJobCategory -SqlInstance $script:instance2 -Category 'dbatoolsci_job_category' -Confirm:$false
}
Describe "$CommandName Integration Tests" -Tags "IntegrationTests" {

Context "Command finds jobs using all parameters" {
BeforeAll {
#subsystemServer needs the real underlying name, and it doesn't work if targeting something like localhost\namedinstance
# the typical error would be WARNING: [17:19:26][New-DbaAgentJobStep] Something went wrong creating the job step | The specified '@server' is
#invalid (valid values are returned by sp_helpserver).
$srvName = Invoke-DbaQuery -SqlInstance $script:instance2 -Query "select @@servername as sn" -as PSObject
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about using -As SingleValue and replacing $srvName.sn by $srvName?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, that would work, too.

$null = New-DbaAgentJob -SqlInstance $script:instance2 -Job 'dbatoolsci_testjob' -OwnerLogin 'sa'
$null = New-DbaAgentJobStep -SqlInstance $script:instance2 -Job 'dbatoolsci_testjob' -StepId 1 -StepName 'dbatoolsci Failed' -Subsystem TransactSql -SubsystemServer $srvName.sn -Command "RAISERROR (15600,-1,-1, 'dbatools_error');" -CmdExecSuccessCode 0 -OnSuccessAction QuitWithSuccess -OnFailAction QuitWithFailure -Database master -RetryAttempts 1 -RetryInterval 2
$null = Start-DbaAgentJob -SqlInstance $script:instance2 -Job 'dbatoolsci_testjob'
$null = New-DbaAgentJob -SqlInstance $script:instance2 -Job 'dbatoolsci_testjob' -OwnerLogin 'sa'
$null = New-DbaAgentJobStep -SqlInstance $script:instance2 -Job 'dbatoolsci_testjob' -StepId 1 -StepName 'dbatoolsci Failed' -Subsystem TransactSql -SubsystemServer $srvName.sn -Command "RAISERROR (15600,-1,-1, 'dbatools_error');" -CmdExecSuccessCode 0 -OnSuccessAction QuitWithSuccess -OnFailAction QuitWithFailure -Database master -RetryAttempts 1 -RetryInterval 2
$null = New-DbaAgentJobCategory -SqlInstance $script:instance2 -Category 'dbatoolsci_job_category' -CategoryType LocalJob
$null = New-DbaAgentJob -SqlInstance $script:instance2 -Job 'dbatoolsci_testjob_disabled' -Category 'dbatoolsci_job_category' -Disabled
$null = New-DbaAgentJobStep -SqlInstance $script:instance2 -Job 'dbatoolsci_testjob_disabled' -StepId 1 -StepName 'dbatoolsci Test Step' -Subsystem TransactSql -SubsystemServer $srvName.sn -Command 'SELECT * FROM master.sys.all_columns' -CmdExecSuccessCode 0 -OnSuccessAction QuitWithSuccess -OnFailAction QuitWithFailure -Database master -RetryAttempts 1 -RetryInterval 2
}
AfterAll {
$null = Remove-DbaAgentJob -SqlInstance $script:instance2 -Job dbatoolsci_testjob, dbatoolsci_testjob_disabled -Confirm:$false
$null = Remove-DbaAgentJobCategory -SqlInstance $script:instance2 -Category 'dbatoolsci_job_category' -Confirm:$false
}

$results = Find-DbaAgentJob -SqlInstance $script:instance2 -Job dbatoolsci_testjob
It "Should find a specific job" {
$results.name | Should Be "dbatoolsci_testjob"
Expand Down Expand Up @@ -55,9 +63,9 @@ Describe "$commandname Integration Tests" -Tags "IntegrationTests" {
It "Should find jobs that have not been scheduled" {
$results | Should not be null
}
$results = Find-DbaAgentJob -SqlInstance $script:instance2 -IsNotScheduled
It "Should find 11 jobs that have no schedule" {
$results.count | Should be 13
$results = Find-DbaAgentJob -SqlInstance $script:instance2 -IsNotScheduled -Job *dbatoolsci*
It "Should find 2 jobs that have no schedule" {
$results.count | Should be 2
}
$results = Find-DbaAgentJob -SqlInstance $script:instance2 -IsNoEmailNotification
It "Should find jobs that have no email notification" {
Expand All @@ -71,6 +79,8 @@ Describe "$commandname Integration Tests" -Tags "IntegrationTests" {
It "Should find jobs that are owned by sa" {
$results | Should not be null
}


$results = Find-DbaAgentJob -SqlInstance $script:instance2 -IsFailed -Since '2016-07-01 10:47:00'
It "Should find jobs that have been failed since July of 2016" {
$results | Should not be null
Expand Down
14 changes: 0 additions & 14 deletions tests/Find-DbaTrigger.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,6 @@ $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" {
[object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object { $_ -notin ('whatif', 'confirm') }
[object[]]$knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'ExcludeDatabase', 'Pattern', 'TriggerLevel', 'IncludeSystemObjects', 'IncludeSystemDatabases', 'EnableException'
$knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters
It "Should only contain our specific parameters" {
(@(Compare-Object -ReferenceObject ($knownParameters | Where-Object { $_ }) -DifferenceObject $params).Count ) | Should Be 0
}
}
}
$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" {
[object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object { $_ -notin ('whatif', 'confirm') }
Expand Down
3 changes: 1 addition & 2 deletions tests/Get-DbaBackupInformation.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ Describe "$CommandName Integration Tests" -Tags "IntegrationTests" {
}

AfterAll {
$null = Get-DbaDatabase -SqlInstance $script:instance1 -Database $dbname | Remove-DbaDatabase -Confirm:$false
$null = Get-DbaDatabase -SqlInstance $script:instance1 -Database $dbname2 | Remove-DbaDatabase -Confirm:$false
$null = Get-DbaDatabase -SqlInstance $script:instance1 -Database $dbname, $dbname2, $dbname3 | Remove-DbaDatabase -Confirm:$false
}

Context "Get history for all database" {
Expand Down
5 changes: 4 additions & 1 deletion tests/Get-DbaDbCompatibility.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ Describe "$commandname Integration Tests" -Tags "IntegrationTests" {
}
Foreach ($row in $results) {
It "Should return correct compatibility level for $($row.database)" {
$row.Compatibility | Should Be $compatibilityLevel
# Only test system databases as there might be leftover databases from other tests
if ($row.DatabaseId -le 4) {
$row.Compatibility | Should Be $compatibilityLevel
}
$row.DatabaseId | Should -Be (Get-DbaDatabase -SqlInstance $script:instance1 -Database $row.Database).Id
}
}
Expand Down
1 change: 1 addition & 0 deletions tests/Get-DbaDump.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ if (-not $env:appveyor) {
BeforeAll {
$server = Connect-DbaInstance -SqlInstance $script:instance1
$server.Query("DBCC STACKDUMP")
Start-Sleep -Seconds 5
}

$results = Get-DbaDump -SqlInstance $script:instance1
Expand Down
2 changes: 1 addition & 1 deletion tests/Get-DbaLastGoodCheckDb.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Describe "$CommandName Integration Tests" -Tag "IntegrationTests" {
$db.Query("DBCC CHECKDB")
}
AfterAll {
$null = Remove-DbaDatabase -SqlInstance $script:instance2 -Database $dbname -confirm:$false
$null = Remove-DbaDatabase -SqlInstance $script:instance1 -Database $dbname -confirm:$false
}
Context "Command actually works" {
$results = Get-DbaLastGoodCheckDb -SqlInstance $script:instance1 -Database master
Expand Down
3 changes: 0 additions & 3 deletions tests/Get-DbaPermission.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,6 @@ Describe "$CommandName Integration Tests" -Tag "IntegrationTests" {
$null = Invoke-DbaQuery -SqlInstance $server -Database $dbName -Query "GRANT CONTROL ON Schema::$schemaNameForTable2 TO $loginNameUser2"

$table2 = New-DbaDbTable -SqlInstance $server -Database $dbName -Name $tableName2 -Schema $schemaNameForTable2 -ColumnMap $tableSpec2

# debugging errors seen only in AppVeyor
Write-Host "Get-DbaPermission: Server=$server, dbName=$dbName, loginDBO=$($loginDBO.Name), loginDBOwner=$($loginDBOwner.Name), loginUser1=$($loginUser1.Name), newUserDBOwner=$($newUserDBOwner.Name), newUser1=$($newUser1.Name), table1=$($table1.Name), loginUser2=$($loginUser2.Name), newUser2=$($newUser2.Name), table2=$($table2.Name), table2Schema=$($table2.Schema)"
}

AfterAll {
Expand Down
3 changes: 0 additions & 3 deletions tests/Get-DbaPfDataCollectorCounterSample.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ Describe "$CommandName Unit Tests" -Tag 'UnitTests' {
}
}
}
$CommandName = $MyInvocation.MyCommand.Name.Replace(".Tests.ps1", "")
Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan
. "$PSScriptRoot\constants.ps1"

Describe "$CommandName Integration Tests" -Tags "IntegrationTests" {
Context "Verifying command works" {
Expand Down
4 changes: 1 addition & 3 deletions tests/Install-DbaAgentAdminAlert.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ Describe "$CommandName Unit Tests" -Tag 'UnitTests' {

Describe "$CommandName Integration Tests" -Tags "IntegrationTests" {
BeforeEach {
if ($Env:appveyor) {
Get-DbaAgentAlert -SqlInstance $script:instance2, $script:instance3 | Remove-DbaAgentAlert -Confirm:$false
}
Get-DbaAgentAlert -SqlInstance $script:instance2, $script:instance3 | Remove-DbaAgentAlert -Confirm:$false
}
Context 'Creating a new SQL Server Agent alert' {
$parms = @{
Expand Down
6 changes: 3 additions & 3 deletions tests/Invoke-DbaBalanceDataFiles.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ Describe "$CommandName Integration Tests" -Tags "IntegrationTests" {
$db = Get-DbaDatabase -SqlInstance $server -Database $dbname

# Create the tables
$db.Query("CREATE TABLE table1 (ID1 INT IDENTITY PRIMARY KEY, Name1 varchar(100))")
$db.Query("CREATE TABLE table2 (ID1 INT IDENTITY PRIMARY KEY, Name2 varchar(100))")
$db.Query("CREATE TABLE table1 (ID1 INT IDENTITY PRIMARY KEY, Name1 char(100))")
$db.Query("CREATE TABLE table2 (ID1 INT IDENTITY PRIMARY KEY, Name2 char(100))")

# Generate the values
$sqlvalues = New-Object System.Collections.ArrayList
1 .. 1000 | ForEach-Object { $null = $sqlvalues.Add("('some value to test the balance command $_')") }
1 .. 1000 | ForEach-Object { $null = $sqlvalues.Add("('some value')") }

$db.Query("insert into table1 (Name1) Values $($sqlvalues -join ',')")
$db.Query("insert into table1 (Name1) Values $($sqlvalues -join ',')")
Expand Down
4 changes: 2 additions & 2 deletions tests/Invoke-DbaDiagnosticQuery.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ Describe "$CommandName Integration Tests" -Tags "IntegrationTests" {
@($results | Where-Object {$_.Database -eq $Database2}).Count | Should -Be 0
}
It "Correctly excludes queries when QueryName and ExcludeQuery parameters are used" {
$results = Invoke-DbaDiagnosticQuery -SqlInstance $script:instance2 -QueryName 'Version Info', 'Core Counts', 'Server Properties' -ExcludeQuery 'Core Counts' -WhatIf
$results = Invoke-DbaDiagnosticQuery -SqlInstance $script:instance2 -QueryName 'Version Info', 'Core Counts', 'Server Properties' -ExcludeQuery 'Core Counts'
@($results).Count | Should be 2
}
It "Correctly excludes queries when only ExcludeQuery parameter is used" {
$results = Invoke-DbaDiagnosticQuery -SqlInstance $script:instance2 -ExcludeQuery "Missing Index Warnings", "Buffer Usage" -whatif
$results = Invoke-DbaDiagnosticQuery -SqlInstance $script:instance2 -ExcludeQuery "Missing Index Warnings", "Buffer Usage"
@($results).Count | Should -BeGreaterThan 0
@($results | Where-Object Name -eq "Missing Index Warnings").Count | Should be 0
@($results | Where-Object Name -eq "Buffer Usage").Count | Should be 0
Expand Down
Loading
Loading