diff --git a/.aider/aider.psm1 b/.aider/aider.psm1 index abb727a196..1dd338676f 100644 --- a/.aider/aider.psm1 +++ b/.aider/aider.psm1 @@ -26,15 +26,14 @@ function Update-PesterTest { The path to the file containing cached conventions. .PARAMETER MaxFileSize - The maximum size of test files to process, in bytes. Files larger than this will be skipped. - Defaults to 7.5kb. + The maximum size of test files to process in a single pass, in bytes. Files larger than this will be processed + in segmented passes using prompts from the segmented directory. Defaults to 7.5kb. .PARAMETER Model The AI model to use (e.g., azure/gpt-4o, gpt-4o-mini, claude-3-5-sonnet). - .NOTES - Tags: Testing, Pester - Author: dbatools team + .PARAMETER EditFormat + Specifies the format for edits. Choices include "whole", "diff", "diff-fenced", "unified diff", "editor-diff", "editor-whole". .EXAMPLE PS C:\> Update-PesterTest @@ -63,24 +62,19 @@ function Update-PesterTest { [int]$First = 10000, [int]$Skip, [string[]]$PromptFilePath = "/workspace/.aider/prompts/template.md", - [string[]]$CacheFilePath = @("/workspace/.aider/prompts/conventions.md","/workspace/private/testing/Get-TestConfig.ps1"), + [string[]]$CacheFilePath = @("/workspace/.aider/prompts/conventions.md", "/workspace/private/testing/Get-TestConfig.ps1"), [int]$MaxFileSize = 7.5kb, - [string]$Model + [string]$Model, + [string]$LargeFileModel = "gpt-4o-mini", + [ValidateSet("whole", "diff", "diff-fenced", "unified diff", "editor-diff", "editor-whole")] + [string]$EditFormat ) begin { - # Full prompt path - if (-not (Get-Module dbatools.library -ListAvailable)) { - Write-Warning "dbatools.library not found, installing" - Install-Module dbatools.library -Scope CurrentUser -Force - } - Import-Module /workspace/dbatools.psm1 -Force - - $promptTemplate = Get-Content $PromptFilePath - $commonParameters = [System.Management.Automation.PSCmdlet]::CommonParameters $commandsToProcess = @() } process { + # Populate commandsToProcess based on InputObject or fallback to default if ($InputObject) { foreach ($item in $InputObject) { Write-Verbose "Processing input object of type: $($item.GetType().FullName)" @@ -89,30 +83,18 @@ function Update-PesterTest { $commandsToProcess += $item } elseif ($item -is [System.IO.FileInfo]) { $path = $item.FullName - Write-Verbose "Processing FileInfo path: $path" if (Test-Path $path) { $cmdName = [System.IO.Path]::GetFileNameWithoutExtension($path) -replace '\.Tests$', '' - Write-Verbose "Extracted command name: $cmdName" $cmd = Get-Command -Name $cmdName -ErrorAction SilentlyContinue - if ($cmd) { - $commandsToProcess += $cmd - } else { - Write-Warning "Could not find command for test file: $path" - } + if ($cmd) { $commandsToProcess += $cmd } + else { Write-Warning "No command found for test file: $path" } } } elseif ($item -is [string]) { - Write-Verbose "Processing string path: $item" if (Test-Path $item) { $cmdName = [System.IO.Path]::GetFileNameWithoutExtension($item) -replace '\.Tests$', '' - Write-Verbose "Extracted command name: $cmdName" $cmd = Get-Command -Name $cmdName -ErrorAction SilentlyContinue - if ($cmd) { - $commandsToProcess += $cmd - } else { - Write-Warning "Could not find command for test file: $item" - } - } else { - Write-Warning "File not found: $item" + if ($cmd) { $commandsToProcess += $cmd } + else { Write-Warning "No command found for test file: $item" } } } else { Write-Warning "Unsupported input type: $($item.GetType().FullName)" @@ -122,59 +104,83 @@ function Update-PesterTest { } end { + # Get default commands if no specific InputObject provided if (-not $commandsToProcess) { - Write-Verbose "No input objects provided, getting commands from dbatools module" $commandsToProcess = Get-Command -Module dbatools -Type Function, Cmdlet | Select-Object -First $First -Skip $Skip } foreach ($command in $commandsToProcess) { $cmdName = $command.Name $filename = "/workspace/tests/$cmdName.Tests.ps1" - - Write-Verbose "Processing command: $cmdName" - Write-Verbose "Test file path: $filename" + $parameters = $command.Parameters.Values | Where-Object Name -notin $commonParameters if (-not (Test-Path $filename)) { Write-Warning "No tests found for $cmdName" - Write-Warning "$filename not found" continue } - <# Check if it's already been converted #> if (Select-String -Path $filename -Pattern "HaveParameter") { - Write-Warning "Skipping $cmdName because it's already been converted to Pester v5" + Write-Warning "Skipping $cmdName, already converted to Pester v5" continue } - # if file is larger than MaxFileSize, skip + # Determine processing mode based on file size if ((Get-Item $filename).Length -gt $MaxFileSize) { - Write-Warning "Skipping $cmdName because it's too large" - continue - } + # Process large files in segmented passes + if ($PSBoundParameters.PrompFilePath) { + $files = $PSBoundParameters.PromptFilePath + } else { + $files = Get-ChildItem -Path "/workspace/.aider/prompts/segmented" -Filter "*.md" + } - $parameters = $command.Parameters.Values | Where-Object Name -notin $commonParameters - $cmdPrompt = $promptTemplate -replace "--CMDNAME--", $cmdName - $cmdPrompt = $cmdPrompt -replace "--PARMZ--", ($parameters.Name -join "`n") - $cmdprompt = $cmdPrompt -join "`n" - - if ($PSCmdlet.ShouldProcess($filename, "Update Pester test to v5 format and/or style")) { - $aiderParams = @{ - Message = $cmdPrompt - File = $filename - YesAlways = $true - NoStream = $true - CachePrompts = $true - ReadFile = $CacheFilePath - Model = $Model + foreach ($file in $files) { + $cmdPrompt = (Get-Content $file.FullName) -join "`n" + $cmdPrompt = $cmdPrompt -replace "--CMDNAME--", $cmdName + $cmdPrompt = $cmdPrompt -replace "--PARMZ--", ($parameters.Name -join "`n") + + if ($PSCmdlet.ShouldProcess($filename, "Update Pester test to v5 format - Segmented Pass")) { + $aiderParams = @{ + Message = $cmdPrompt + File = $filename + YesAlways = $true + NoStream = $true + CachePrompts = $true + Model = $LargeFileModel + EditFormat = if ($EditFormat) { $EditFormat } else { "whole" } + } + + Write-Verbose "Invoking Aider for segmented pass on $filename using $($file.Name)" + Invoke-Aider @aiderParams + } } + } else { + # Process smaller files normally + $cmdPrompt = (Get-Content $PromptFilePath) -join "`n" + $cmdPrompt = $cmdPrompt -replace "--CMDNAME--", $cmdName + $cmdPrompt = $cmdPrompt -replace "--PARMZ--", ($parameters.Name -join "`n") + + if ($PSCmdlet.ShouldProcess($filename, "Update Pester test to v5 format")) { + $aiderParams = @{ + Message = $cmdPrompt + File = $filename + YesAlways = $true + NoStream = $true + CachePrompts = $true + ReadFile = $CacheFilePath + Model = $Model + EditFormat = if ($EditFormat) { $EditFormat } else { "whole" } + } - Write-Verbose "Invoking Aider to update test file" - Invoke-Aider @aiderParams + Write-Verbose "Invoking Aider to update test file normally" + Invoke-Aider @aiderParams + } } } } } + + function Repair-Error { <# .SYNOPSIS @@ -273,7 +279,7 @@ function Repair-SmallThing { [int]$Skip, [string]$Model = "azure/gpt-4o-mini", [string[]]$PromptFilePath, - [ValidateSet("ReorgParamTest")] + [ValidateSet("ReorgParamTest", "StartNewFile", "RefactorParamTest", "RemoveLines")] [string]$Type, [string]$EditorModel, [switch]$NoPretty, @@ -286,6 +292,7 @@ function Repair-SmallThing { [switch]$NoAutoLint, [switch]$AutoTest, [switch]$ShowPrompts, + [ValidateSet("whole", "diff", "diff-fenced", "unified diff", "editor-diff", "editor-whole")] [string]$EditFormat, [string]$MessageFile, [string[]]$ReadFile, @@ -297,32 +304,9 @@ function Repair-SmallThing { $allObjects = @() $prompts = @{ - ReorgParamTest = 'Move the `$expected` parameter list AND the `$command` setting into the BeforeAll block immediately under Describe. - - If you cannot find the $expected` parameter list, do not make any changes. - - BAD: - Describe "Backup-DbaDbMasterKey" -Tag "UnitTests" { - Context "Parameter validation" { - BeforeAll { - $command = Get-Command Backup-DbaDbMasterKey - $expected = $TestConfig.CommonParameters - $expected += @( - "SqlInstance", - "SqlCredential", - "Credential", - "Database", - "ExcludeDatabase", - "SecurePassword", - "Path", - "InputObject", - "EnableException", - "WhatIf", - "Confirm" - ) - } + ReorgParamTest = ' + The parameter test should look like this (not actual parameters) - GOOD: Describe "Backup-DbaDbMasterKey" -Tag "UnitTests" { BeforeAll { $command = Get-Command Backup-DbaDbMasterKey @@ -345,16 +329,6 @@ function Repair-SmallThing { } Write-Verbose "Available prompt types: $($prompts.Keys -join ', ')" - Write-Verbose "Checking for dbatools.library module" - if (-not (Get-Module dbatools.library -ListAvailable)) { - Write-Verbose "dbatools.library not found, installing" - Install-Module dbatools.library -Scope CurrentUser -Force -Verbose:$false - } - if (-not (Get-Module dbatools)) { - Write-Verbose "Importing dbatools module from /workspace/dbatools.psm1" - Import-Module /workspace/dbatools.psm1 -Force -Verbose:$false - } - if ($PromptFilePath) { Write-Verbose "Loading prompt template from $PromptFilePath" $promptTemplate = Get-Content $PromptFilePath @@ -588,6 +562,7 @@ function Invoke-Aider { [switch]$NoAutoLint, [switch]$AutoTest, [switch]$ShowPrompts, + [ValidateSet("whole", "diff", "diff-fenced", "unified diff", "editor-diff", "editor-whole")] [string]$EditFormat, [string]$MessageFile, [string[]]$ReadFile, @@ -779,4 +754,16 @@ function Repair-Error { Invoke-Aider @aiderParams } -} \ No newline at end of file +} + + +Write-Verbose "Checking for dbatools.library module" +if (-not (Get-Module dbatools.library -ListAvailable)) { + Write-Verbose "dbatools.library not found, installing" + Install-Module dbatools.library -Scope CurrentUser -Force -Verbose:$false +} + +if (-not (Get-Command Get-DbaDatabase -ErrorAction SilentlyContinue)) { + Write-Verbose "Importing dbatools module from /workspace/dbatools.psm1" + Import-Module /workspace/dbatools.psm1 -Force -Verbose:$false +} diff --git a/.aider/prompts/segmented/Core.Setup.md b/.aider/prompts/segmented/Core.Setup.md new file mode 100644 index 0000000000..17d6ed7cdf --- /dev/null +++ b/.aider/prompts/segmented/Core.Setup.md @@ -0,0 +1,9 @@ +## Core Requirements +```powershell +#Requires -Module @{ ModuleName="Pester"; ModuleVersion="5.0"} +param( + $ModuleName = "dbatools", + $PSDefaultParameterValues = ($TestConfig = Get-TestConfig).Defaults +) +``` +These lines must start every test file. \ No newline at end of file diff --git a/.aider/prompts/segmented/ParameterTest.md b/.aider/prompts/segmented/ParameterTest.md new file mode 100644 index 0000000000..d48e4e6411 --- /dev/null +++ b/.aider/prompts/segmented/ParameterTest.md @@ -0,0 +1,18 @@ +The parameter test should look like this: + +Describe "Backup-DbaDbMasterKey" -Tag "UnitTests" { + BeforeAll { + $command = Get-Command Backup-DbaDbMasterKey + $expected = $TestConfig.CommonParameters + $expected += @( + "SqlInstance", + "SqlCredential", + "WhatIf", + "Confirm" + ) + } + Context "Parameter validation" {... + +But with these parameters: + +--PARMZ-- \ No newline at end of file diff --git a/.aider/prompts/segmented/Splatting.md b/.aider/prompts/segmented/Splatting.md new file mode 100644 index 0000000000..38fe752f9b Binary files /dev/null and b/.aider/prompts/segmented/Splatting.md differ diff --git a/.aider/prompts/segmented/Structural.Revisions.Context.md b/.aider/prompts/segmented/Structural.Revisions.Context.md new file mode 100644 index 0000000000..0f5c061264 --- /dev/null +++ b/.aider/prompts/segmented/Structural.Revisions.Context.md @@ -0,0 +1,4 @@ +### Context Blocks +- Describe specific scenarios or states +- Use clear, descriptive names that explain the test scenario +- Example: "When getting all databases", "When database is offline" \ No newline at end of file diff --git a/.aider/prompts/segmented/Structural.Revisions.Describe.md b/.aider/prompts/segmented/Structural.Revisions.Describe.md new file mode 100644 index 0000000000..d3531cae0e Binary files /dev/null and b/.aider/prompts/segmented/Structural.Revisions.Describe.md differ diff --git a/.aider/prompts/segmented/Structure.Refinement.md b/.aider/prompts/segmented/Structure.Refinement.md new file mode 100644 index 0000000000..680175cdb2 Binary files /dev/null and b/.aider/prompts/segmented/Structure.Refinement.md differ diff --git a/.aider/prompts/segmented/Style.Guidelines.md b/.aider/prompts/segmented/Style.Guidelines.md new file mode 100644 index 0000000000..1dd4db3d61 Binary files /dev/null and b/.aider/prompts/segmented/Style.Guidelines.md differ diff --git a/.aider/prompts/segmented/Syntax.Refinement.md b/.aider/prompts/segmented/Syntax.Refinement.md new file mode 100644 index 0000000000..cbcfd4085f --- /dev/null +++ b/.aider/prompts/segmented/Syntax.Refinement.md @@ -0,0 +1,4 @@ +### Syntax Requirements +- Use $PSItem instead of $_ +- No trailing spaces +- Use $results.Status.Count for accurate counting \ No newline at end of file diff --git a/.aider/prompts/segmented/Test.Code.Placement.md b/.aider/prompts/segmented/Test.Code.Placement.md new file mode 100644 index 0000000000..8ecf1fddfd Binary files /dev/null and b/.aider/prompts/segmented/Test.Code.Placement.md differ diff --git a/tests/Backup-DbaDatabase.Tests.ps1 b/tests/Backup-DbaDatabase.Tests.ps1 index 1ffcfdf525..3f88e2b7d4 100644 --- a/tests/Backup-DbaDatabase.Tests.ps1 +++ b/tests/Backup-DbaDatabase.Tests.ps1 @@ -1,32 +1,78 @@ +#Requires -Module @{ ModuleName="Pester"; ModuleVersion="5.0"} +param( + $ModuleName = "dbatools", + $PSDefaultParameterValues = ($TestConfig = Get-TestConfig).Defaults +) $CommandName = $MyInvocation.MyCommand.Name.Replace(".Tests.ps1", "") Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan $global:TestConfig = Get-TestConfig -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', 'Path', 'FilePath', 'ReplaceInName', 'NoAppendDbNameInPath', 'CopyOnly', 'Type', 'InputObject', 'CreateFolder', 'FileCount', 'CompressBackup', 'Checksum', 'Verify', 'MaxTransferSize', 'BlockSize', 'BufferCount', 'AzureBaseUrl', 'AzureCredential', 'NoRecovery', 'BuildPath', 'WithFormat', 'Initialize', 'SkipTapeHeader', 'TimeStampFormat', 'IgnoreFileChecks', 'OutputScriptOnly', 'EnableException', 'EncryptionAlgorithm', 'EncryptionCertificate', 'IncrementPrefix', 'Description' - $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters +Describe "Backup-DbaDatabase" -Tag "UnitTests" { + BeforeAll { + $command = Get-Command Backup-DbaDatabase + $expected = $TestConfig.CommonParameters + $expected += @( + "SqlInstance", + "SqlCredential", + "Database", + "ExcludeDatabase", + "Path", + "FilePath", + "IncrementPrefix", + "ReplaceInName", + "NoAppendDbNameInPath", + "CopyOnly", + "Type", + "InputObject", + "CreateFolder", + "FileCount", + "CompressBackup", + "Checksum", + "Verify", + "MaxTransferSize", + "BlockSize", + "BufferCount", + "AzureBaseUrl", + "AzureCredential", + "NoRecovery", + "BuildPath", + "WithFormat", + "Initialize", + "SkipTapeHeader", + "TimeStampFormat", + "IgnoreFileChecks", + "OutputScriptOnly", + "EncryptionAlgorithm", + "EncryptionCertificate", + "Description", + "EnableException", + "Verbose", + "Debug", + "ErrorAction", + "WarningAction", + "InformationAction", + "ProgressAction", + "ErrorVariable", + "WarningVariable", + "InformationVariable", + "OutVariable", + "OutBuffer", + "PipelineVariable", + "WhatIf", + "Confirm" + ) + } + Context "When validating parameters" { + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object { $PSItem -notin "WhatIf", "Confirm" } It "Should only contain our specific parameters" { - (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object { $_ }) -DifferenceObject $params).Count ) | Should Be 0 + (@(Compare-Object -ReferenceObject ($expected | Where-Object { $PSItem }) -DifferenceObject $params).Count) | Should Be 0 } } } -Describe "$commandname Integration Tests" -Tags "IntegrationTests" { - - Context "Properly restores a database on the local drive using Path" { - $results = Backup-DbaDatabase -SqlInstance $TestConfig.instance1 -BackupDirectory C:\temp\backups - It "Should return a database name, specifically master" { - ($results.DatabaseName -contains 'master') | Should -Be $true - } - It "Should return successful restore" { - $results.ForEach{ $_.BackupComplete | Should -Be $true } - } - } - +Describe "Backup-DbaDatabase" -Tag "IntegrationTests" { BeforeAll { - $DestBackupDir = 'C:\Temp\backups' + $DestBackupDir = "C:\Temp\backups" $random = Get-Random $DestDbRandom = "dbatools_ci_backupdbadatabase$random" if (-Not(Test-Path $DestBackupDir)) { @@ -42,15 +88,32 @@ Describe "$commandname Integration Tests" -Tags "IntegrationTests" { Remove-Item "$DestBackupDir\*" -Force -Recurse } } - Context "Should not backup if database and exclude match" { - $results = Backup-DbaDatabase -SqlInstance $TestConfig.instance1 -BackupDirectory $DestBackupDir -Database master -Exclude master + + Context "When restoring a database on the local drive using Path" { + BeforeEach { + $results = Backup-DbaDatabase -SqlInstance $TestConfig.instance1 -BackupDirectory "C:\temp\backups" + } + It "Should return a database name, specifically master" { + ($results.DatabaseName -contains "master") | Should -Be $true + } + It "Should return successful restore" { + $results.ForEach{ $PSItem.BackupComplete | Should -Be $true } + } + } + + Context "When database and exclude match" { + BeforeEach { + $results = Backup-DbaDatabase -SqlInstance $TestConfig.instance1 -BackupDirectory $DestBackupDir -Database "master" -Exclude "master" + } It "Should not return object" { $results | Should -Be $null } } - Context "No database found to backup should raise warning and null output" { - $results = Backup-DbaDatabase -SqlInstance $TestConfig.instance1 -BackupDirectory $DestBackupDir -Database AliceDoesntDBHereAnyMore -WarningVariable warnvar 3> $null + Context "When no database found to backup" { + BeforeEach { + $results = Backup-DbaDatabase -SqlInstance $TestConfig.instance1 -BackupDirectory $DestBackupDir -Database "AliceDoesntDBHereAnyMore" -WarningVariable warnvar 3> $null + } It "Should not return object" { $results | Should -Be $null } @@ -59,8 +122,10 @@ Describe "$commandname Integration Tests" -Tags "IntegrationTests" { } } - Context "Database should backup 1 database" { - $results = Backup-DbaDatabase -SqlInstance $TestConfig.instance1 -BackupDirectory $DestBackupDir -Database master + Context "When backing up a single database" { + BeforeEach { + $results = Backup-DbaDatabase -SqlInstance $TestConfig.instance1 -BackupDirectory $DestBackupDir -Database "master" + } It "Database backup object count Should Be 1" { $results.DatabaseName.Count | Should -Be 1 $results.BackupComplete | Should -Be $true @@ -70,16 +135,20 @@ Describe "$commandname Integration Tests" -Tags "IntegrationTests" { } } - Context "Database should backup 2 databases" { - $results = Backup-DbaDatabase -SqlInstance $TestConfig.instance1 -BackupDirectory $DestBackupDir -Database master, msdb + Context "When backing up multiple databases" { + BeforeEach { + $results = Backup-DbaDatabase -SqlInstance $TestConfig.instance1 -BackupDirectory $DestBackupDir -Database "master", "msdb" + } It "Database backup object count Should Be 2" { $results.DatabaseName.Count | Should -Be 2 $results.BackupComplete | Should -Be @($true, $true) } } - Context "Should take path and filename" { - $results = Backup-DbaDatabase -SqlInstance $TestConfig.instance1 -BackupDirectory $DestBackupDir -Database master -BackupFileName 'PesterTest.bak' + Context "When specifying path and filename" { + BeforeEach { + $results = Backup-DbaDatabase -SqlInstance $TestConfig.instance1 -BackupDirectory $DestBackupDir -Database "master" -BackupFileName "PesterTest.bak" + } It "Should report it has backed up to the path with the correct name" { $results.Fullname | Should -BeLike "$DestBackupDir*PesterTest.bak" } @@ -88,8 +157,10 @@ Describe "$commandname Integration Tests" -Tags "IntegrationTests" { } } - Context "Database parameter works when using pipes (fixes #5044)" { - $results = Get-DbaDatabase -SqlInstance $TestConfig.instance1 | Backup-DbaDatabase -Database master -BackupFileName PesterTest.bak -BackupDirectory $DestBackupDir + Context "When using pipes for database parameter" { + BeforeEach { + $results = Get-DbaDatabase -SqlInstance $TestConfig.instance1 | Backup-DbaDatabase -Database "master" -BackupFileName "PesterTest.bak" -BackupDirectory $DestBackupDir + } It "Should report it has backed up to the path with the correct name" { $results.Fullname | Should -BeLike "$DestBackupDir*PesterTest.bak" } @@ -98,94 +169,110 @@ Describe "$commandname Integration Tests" -Tags "IntegrationTests" { } } - Context "ExcludeDatabase parameter works when using pipes (fixes #5044)" { - $results = Get-DbaDatabase -SqlInstance $TestConfig.instance1 | Backup-DbaDatabase -ExcludeDatabase master, tempdb, msdb, model + Context "When excluding databases using pipes" { + BeforeEach { + $results = Get-DbaDatabase -SqlInstance $TestConfig.instance1 | Backup-DbaDatabase -ExcludeDatabase "master", "tempdb", "msdb", "model" + } It "Should report it has backed up to the path with the correct name" { - $results.DatabaseName | Should -Not -Contain master - $results.DatabaseName | Should -Not -Contain tempdb - $results.DatabaseName | Should -Not -Contain msdb - $results.DatabaseName | Should -Not -Contain model + $results.DatabaseName | Should -Not -Contain "master" + $results.DatabaseName | Should -Not -Contain "tempdb" + $results.DatabaseName | Should -Not -Contain "msdb" + $results.DatabaseName | Should -Not -Contain "model" } } - Context "Handling backup paths that don't exist" { - $MissingPathTrailing = "$DestBackupDir\Missing1\Awol2\" - $MissingPath = "$DestBackupDir\Missing1\Awol2" - $null = Backup-DbaDatabase -SqlInstance $TestConfig.instance1 -Database master -BackupDirectory $MissingPath -WarningVariable warnvar *>$null + Context "When handling non-existent backup paths" { + BeforeEach { + $MissingPathTrailing = "$DestBackupDir\Missing1\Awol2\" + $MissingPath = "$DestBackupDir\Missing1\Awol2" + $null = Backup-DbaDatabase -SqlInstance $TestConfig.instance1 -Database "master" -BackupDirectory $MissingPath -WarningVariable warnvar *>$null + } It "Should warn and fail if path doesn't exist and BuildPath not set" { $warnvar | Should -BeLike "*$MissingPath*" } - # $MissingPathTrailing has a trailing slash but we normalize the path before doing the actual backup - $results = Backup-DbaDatabase -SqlInstance $TestConfig.instance1 -Database master -BackupDirectory $MissingPathTrailing -BuildPath + BeforeEach { + $results = Backup-DbaDatabase -SqlInstance $TestConfig.instance1 -Database "master" -BackupDirectory $MissingPathTrailing -BuildPath + } It "Should have backed up to $MissingPath" { $results.BackupFolder | Should -Be "$MissingPath" - $results.Path | Should -Not -BeLike '*\\*' + $results.Path | Should -Not -BeLike "*\\*" } } - Context "CreateFolder switch should append the databasename to the backup path" { - $results = Backup-DbaDatabase -SqlInstance $TestConfig.instance1 -Database master -BackupDirectory $DestBackupDir -CreateFolder + Context "When using CreateFolder switch" { + BeforeEach { + $results = Backup-DbaDatabase -SqlInstance $TestConfig.instance1 -Database "master" -BackupDirectory $DestBackupDir -CreateFolder + } It "Should have appended master to the backup path" { $results.BackupFolder | Should -Be "$DestBackupDir\master" } } - Context "CreateFolder switch should append the databasename to the backup path even when striping" { - $backupPaths = "$DestBackupDir\stripewithdb1", "$DestBackupDir\stripewithdb2" - $results = Backup-DbaDatabase -SqlInstance $TestConfig.instance1 -Database master -BackupDirectory $backupPaths -CreateFolder + Context "When using CreateFolder switch with striping" { + BeforeEach { + $backupPaths = "$DestBackupDir\stripewithdb1", "$DestBackupDir\stripewithdb2" + $results = Backup-DbaDatabase -SqlInstance $TestConfig.instance1 -Database "master" -BackupDirectory $backupPaths -CreateFolder + } It "Should have appended master to all backup paths" { foreach ($path in $results.BackupFolder) { - ($results.BackupFolder | Sort-Object) | Should -Be ($backupPaths | Sort-Object | ForEach-Object { [IO.Path]::Combine($_, 'master') }) + ($results.BackupFolder | Sort-Object) | Should -Be ($backupPaths | Sort-Object | ForEach-Object { [IO.Path]::Combine($PSItem, "master") }) } } } - - Context "A fully qualified path should override a backupfolder" { - $results = Backup-DbaDatabase -SqlInstance $TestConfig.instance1 -Database master -BackupDirectory c:\temp -BackupFileName "$DestBackupDir\PesterTest2.bak" + Context "When using a fully qualified path" { + BeforeEach { + $results = Backup-DbaDatabase -SqlInstance $TestConfig.instance1 -Database "master" -BackupDirectory "c:\temp" -BackupFileName "$DestBackupDir\PesterTest2.bak" + } It "Should report backed up to $DestBackupDir" { $results.FullName | Should -BeLike "$DestBackupDir\PesterTest2.bak" - $results.BackupFolder | Should Not Be 'c:\temp' + $results.BackupFolder | Should Not Be "c:\temp" } - It "Should have backuped up to $DestBackupDir\PesterTest2.bak" { + It "Should have backed up to $DestBackupDir\PesterTest2.bak" { Test-Path "$DestBackupDir\PesterTest2.bak" | Should -Be $true } } - Context "Should stripe if multiple backupfolders specified" { - $backupPaths = "$DestBackupDir\stripe1", "$DestBackupDir\stripe2", "$DestBackupDir\stripe3" - $null = New-Item -Path $backupPaths -ItemType Directory - - - $results = Backup-DbaDatabase -SqlInstance $TestConfig.instance1 -Database master -BackupDirectory $backupPaths + Context "When multiple backup folders specified" { + BeforeEach { + $backupPaths = "$DestBackupDir\stripe1", "$DestBackupDir\stripe2", "$DestBackupDir\stripe3" + $null = New-Item -Path $backupPaths -ItemType Directory + $results = Backup-DbaDatabase -SqlInstance $TestConfig.instance1 -Database "master" -BackupDirectory $backupPaths + } It "Should have created 3 backups" { $results.BackupFilesCount | Should -Be 3 } It "Should have written to all 3 folders" { $backupPaths | ForEach-Object { - $_ | Should -BeIn ($results.BackupFolder) + $PSItem | Should -BeIn ($results.BackupFolder) } } It "Should have written files with extensions" { foreach ($path in $results.BackupFile) { - [IO.Path]::GetExtension($path) | Should -Be '.bak' + [IO.Path]::GetExtension($PSItem) | Should -Be ".bak" } } - # Assure that striping logic favours -BackupDirectory and not -Filecount - $results = Backup-DbaDatabase -SqlInstance $TestConfig.instance1 -Database master -BackupDirectory $backupPaths -FileCount 2 + BeforeEach { + $results = Backup-DbaDatabase -SqlInstance $TestConfig.instance1 -Database "master" -BackupDirectory $backupPaths -FileCount 2 + } It "Should have created 3 backups, even when FileCount is different" { $results.BackupFilesCount | Should -Be 3 } } - Context "Should stripe on filecount > 1" { - $results = Backup-DbaDatabase -SqlInstance $TestConfig.instance1 -Database master -BackupDirectory $DestBackupDir -FileCount 3 + Context "When file count is greater than 1" { + BeforeEach { + $results = Backup-DbaDatabase -SqlInstance $TestConfig.instance1 -Database "master" -BackupDirectory $DestBackupDir -FileCount 3 + } It "Should have created 3 backups" { $results.BackupFilesCount | Should -Be 3 } } - Context "Should build filenames properly" { + Context "When building filenames" { + BeforeEach { + $results = Backup-DbaDatabase -SqlInstance $TestConfig.instance1 -Database "master" -BackupDirectory $DestBackupDir -FileCount 3 + } It "Should have 1 period in file extension" { foreach ($path in $results.BackupFile) { [IO.Path]::GetExtension($path) | Should -Not -BeLike '*..*' @@ -193,9 +280,11 @@ Describe "$commandname Integration Tests" -Tags "IntegrationTests" { } } - Context "Should prefix the filenames when IncrementPrefix set" { - $fileCount = 3 - $results = Backup-DbaDatabase -SqlInstance $TestConfig.instance1 -Database master -BackupDirectory $DestBackupDir -FileCount $fileCount -IncrementPrefix + Context "When IncrementPrefix is set" { + BeforeEach { + $fileCount = 3 + $results = Backup-DbaDatabase -SqlInstance $TestConfig.instance1 -Database "master" -BackupDirectory $DestBackupDir -FileCount $fileCount -IncrementPrefix + } It "Should have created 3 backups" { $results.BackupFilesCount | Should -Be 3 } @@ -206,78 +295,90 @@ Describe "$commandname Integration Tests" -Tags "IntegrationTests" { } } - Context "Should Backup to default path if none specified" { - $results = Backup-DbaDatabase -SqlInstance $TestConfig.instance1 -Database master -BackupFileName 'PesterTest.bak' - $DefaultPath = (Get-DbaDefaultPath -SqlInstance $TestConfig.instance1).Backup - It "Should report it has backed up to the path with the corrrect name" { + Context "When no backup path is specified" { + BeforeEach { + $results = Backup-DbaDatabase -SqlInstance $TestConfig.instance1 -Database "master" -BackupFileName "PesterTest.bak" + $DefaultPath = (Get-DbaDefaultPath -SqlInstance $TestConfig.instance1).Backup + } + It "Should report it has backed up to the path with the correct name" { $results.Fullname | Should -BeLike "$DefaultPath*PesterTest.bak" } - It "Should have backed up to the path with the corrrect name" { + It "Should have backed up to the path with the correct name" { Test-Path "$DefaultPath\PesterTest.bak" | Should -Be $true } } - Context "Test backup verification" { + Context "When verifying backup" { + BeforeEach { + $b = Backup-DbaDatabase -SqlInstance $TestConfig.instance1 -Database "master" -Type "full" -Verify + } It "Should perform a full backup and verify it" { - $b = Backup-DbaDatabase -SqlInstance $TestConfig.instance1 -Database master -Type full -Verify - $b.BackupComplete | Should -Be $True - $b.Verified | Should -Be $True + $b.BackupComplete | Should -Be $true + $b.Verified | Should -Be $true $b.count | Should -Be 1 } - It -Skip "Should perform a diff backup and verify it" { - $b = Backup-DbaDatabase -SqlInstance $TestConfig.instance1 -Database backuptest -Type diff -Verify - $b.BackupComplete | Should -Be $True - $b.Verified | Should -Be $True + It -Skip $true "Should perform a diff backup and verify it" { + $b = Backup-DbaDatabase -SqlInstance $TestConfig.instance1 -Database "backuptest" -Type "diff" -Verify + $b.BackupComplete | Should -Be $true + $b.Verified | Should -Be $true } - It -Skip "Should perform a log backup and verify it" { - $b = Backup-DbaDatabase -SqlInstance $TestConfig.instance1 -Database backuptest -Type log -Verify - $b.BackupComplete | Should -Be $True - $b.Verified | Should -Be $True + It -Skip $true "Should perform a log backup and verify it" { + $b = Backup-DbaDatabase -SqlInstance $TestConfig.instance1 -Database "backuptest" -Type "log" -Verify + $b.BackupComplete | Should -Be $true + $b.Verified | Should -Be $true } } - Context "Backup can pipe to restore" { - $null = Restore-DbaDatabase -SqlInstance $TestConfig.instance1 -Path "$($TestConfig.appveyorlabrepo)\singlerestore\singlerestore.bak" -DatabaseName "dbatoolsci_singlerestore" - $results = Backup-DbaDatabase -SqlInstance $TestConfig.instance1 -BackupDirectory $DestBackupDir -Database "dbatoolsci_singlerestore" | Restore-DbaDatabase -SqlInstance $TestConfig.instance2 -DatabaseName $DestDbRandom -TrustDbBackupHistory -ReplaceDbNameInFile + Context "When piping backup to restore" { + BeforeEach { + $null = Restore-DbaDatabase -SqlInstance $TestConfig.instance1 -Path "$($TestConfig.appveyorlabrepo)\singlerestore\singlerestore.bak" -DatabaseName "dbatoolsci_singlerestore" + $results = Backup-DbaDatabase -SqlInstance $TestConfig.instance1 -BackupDirectory $DestBackupDir -Database "dbatoolsci_singlerestore" | Restore-DbaDatabase -SqlInstance $TestConfig.instance2 -DatabaseName $DestDbRandom -TrustDbBackupHistory -ReplaceDbNameInFile + } It "Should return successful restore" { $results.RestoreComplete | Should -Be $true } } - Context "Test Backup-DbaDatabase can take pipe input" { - $results = Get-DbaDatabase -SqlInstance $TestConfig.instance1 -Database master | Backup-DbaDatabase -confirm:$false -WarningVariable warnvar 3> $null + Context "When Backup-DbaDatabase can take pipe input" { + BeforeEach { + $results = Get-DbaDatabase -SqlInstance $TestConfig.instance1 -Database "master" | Backup-DbaDatabase -confirm:$false -WarningVariable warnvar 3> $null + } It "Should not warn" { $warnvar | Should -BeNullOrEmpty } It "Should Complete Successfully" { $results.BackupComplete | Should -Be $true } - } - Context "Should handle NUL as an input path" { - $results = Backup-DbaDatabase -SqlInstance $TestConfig.instance1 -Database master -BackupFileName NUL - It "Should return succesful backup" { + Context "When handling NUL as an input path" { + BeforeEach { + $results = Backup-DbaDatabase -SqlInstance $TestConfig.instance1 -Database "master" -BackupFileName "NUL" + } + It "Should return successful backup" { $results.BackupComplete | Should -Be $true } It "Should have backed up to NUL:" { - $results.FullName[0] | Should -Be 'NUL:' + $results.FullName[0] | Should -Be "NUL:" } } - Context "Should only output a T-SQL String if OutputScriptOnly specified" { - $results = Backup-DbaDatabase -SqlInstance $TestConfig.instance1 -Database master -BackupFileName c:\notexists\file.bak -OutputScriptOnly + Context "When OutputScriptOnly is specified" { + BeforeEach { + $results = Backup-DbaDatabase -SqlInstance $TestConfig.instance1 -Database "master" -BackupFileName "c:\notexists\file.bak" -OutputScriptOnly + } It "Should return a string" { - $results.GetType().ToString() | Should -Be 'System.String' + $results.GetType().ToString() | Should -Be "System.String" } It "Should return BACKUP DATABASE [master] TO DISK = N'c:\notexists\file.bak' WITH NOFORMAT, NOINIT, NOSKIP, REWIND, NOUNLOAD, STATS = 1" { $results | Should -Be "BACKUP DATABASE [master] TO DISK = N'c:\notexists\file.bak' WITH NOFORMAT, NOINIT, NOSKIP, REWIND, NOUNLOAD, STATS = 1" } } - Context "Should handle an encrypted database when compression is specified" { - $sqlencrypt = - @" + Context "When handling an encrypted database with compression" { + BeforeEach { + $sqlencrypt = + @" CREATE MASTER KEY ENCRYPTION BY PASSWORD = ''; go CREATE CERTIFICATE MyServerCert WITH SUBJECT = 'My DEK Certificate'; @@ -285,9 +386,9 @@ go CREATE DATABASE encrypted go "@ - $null = Invoke-DbaQuery -SqlInstance $TestConfig.instance2 -Query $sqlencrypt -Database Master - $createdb = - @" + $null = Invoke-DbaQuery -SqlInstance $TestConfig.instance2 -Query $sqlencrypt -Database "Master" + $createdb = + @" CREATE DATABASE ENCRYPTION KEY WITH ALGORITHM = AES_128 ENCRYPTION BY SERVER CERTIFICATE MyServerCert; @@ -296,84 +397,95 @@ ALTER DATABASE encrypted SET ENCRYPTION ON; GO "@ - $null = Invoke-DbaQuery -SqlInstance $TestConfig.instance2 -Query $createdb -Database encrypted + $null = Invoke-DbaQuery -SqlInstance $TestConfig.instance2 -Query $createdb -Database "encrypted" + } It "Should compress an encrypted db" { - $results = Backup-DbaDatabase -SqlInstance $TestConfig.instance2 -Database encrypted -Compress + $results = Backup-DbaDatabase -SqlInstance $TestConfig.instance2 -Database "encrypted" -Compress Invoke-Command2 -ComputerName $TestConfig.instance2 -ScriptBlock { Remove-Item -Path $args[0] } -ArgumentList $results.FullName - $results.script | Should -BeLike '*D, COMPRESSION,*' + $results.script | Should -BeLike "*D, COMPRESSION,*" } - Remove-DbaDatabase -SqlInstance $TestConfig.instance2 -Database encrypted -confirm:$false - $sqldrop = - @" + AfterAll { + Remove-DbaDatabase -SqlInstance $TestConfig.instance2 -Database "encrypted" -confirm:$false + $sqldrop = + @" drop certificate MyServerCert go drop master key go "@ - $null = Invoke-DbaQuery -SqlInstance $TestConfig.instance2 -Query $sqldrop -Database Master + $null = Invoke-DbaQuery -SqlInstance $TestConfig.instance2 -Query $sqldrop -Database "Master" + } } - Context "Custom TimeStamp" { - # Test relies on DateFormat bobob returning bobob as the values aren't interpreted, check here in case .Net rules change - $results = Backup-DbaDatabase -SqlInstance $TestConfig.instance1 -Database master -BackupDirectory $DestBackupDir -TimeStampFormat bobob - It "Should apply the corect custom Timestamp" { - ($results | Where-Object { $_.BackupPath -like '*bobob*' }).count | Should -Be $results.count + Context "When applying custom TimeStamp" { + BeforeEach { + $results = Backup-DbaDatabase -SqlInstance $TestConfig.instance1 -Database "master" -BackupDirectory $DestBackupDir -TimeStampFormat "bobob" + } + It "Should apply the correct custom Timestamp" { + ($results | Where-Object { $PSItem.BackupPath -like "*bobob*" }).count | Should -Be $results.Status.Count } } - Context "Test Backup templating" { - $results = Backup-DbaDatabase -SqlInstance $TestConfig.instance1 -Database master, msdb -BackupDirectory $DestBackupDir\dbname\instancename\backuptype\ -BackupFileName dbname-backuptype.bak -ReplaceInName -BuildPath + Context "When testing backup templating" { + BeforeEach { + $results = Backup-DbaDatabase -SqlInstance $TestConfig.instance1 -Database "master", "msdb" -BackupDirectory "$DestBackupDir\dbname\instancename\backuptype\" -BackupFileName "dbname-backuptype.bak" -ReplaceInName -BuildPath + } It "Should have replaced the markers" { $results[0].BackupPath | Should -BeLike "$DestBackupDir\master\$(($TestConfig.instance1).split('\')[1])\Full\master-Full.bak" $results[1].BackupPath | Should -BeLike "$DestBackupDir\msdb\$(($TestConfig.instance1).split('\')[1])\Full\msdb-Full.bak" } } - Context "Test Backup templating when db object piped in issue 8100" { - $results = Get-DbaDatabase -SqlInstance $TestConfig.instance1 -Database master,msdb | Backup-DbaDatabase -BackupDirectory $DestBackupDir\db2\dbname\instancename\backuptype\ -BackupFileName dbname-backuptype.bak -ReplaceInName -BuildPath + Context "When testing backup templating with piped db object" { + BeforeEach { + $results = Get-DbaDatabase -SqlInstance $TestConfig.instance1 -Database "master", "msdb" | Backup-DbaDatabase -BackupDirectory "$DestBackupDir\db2\dbname\instancename\backuptype\" -BackupFileName "dbname-backuptype.bak" -ReplaceInName -BuildPath + } It "Should have replaced the markers" { $results[0].BackupPath | Should -BeLike "$DestBackupDir\db2\master\$(($TestConfig.instance1).split('\')[1])\Full\master-Full.bak" $results[1].BackupPath | Should -BeLike "$DestBackupDir\db2\msdb\$(($TestConfig.instance1).split('\')[1])\Full\msdb-Full.bak" } } - Context "Test Backup Encryption with Certificate" { - $securePass = ConvertTo-SecureString "estBackupDir\master\script:instance1).split('\')[1])\Full\master-Full.bak" -AsPlainText -Force - New-DbaDbMasterKey -SqlInstance $TestConfig.instance2 -Database Master -SecurePassword $securePass -confirm:$false -ErrorAction SilentlyContinue - $cert = New-DbaDbCertificate -SqlInstance $TestConfig.instance2 -Database master -Name BackupCertt -Subject BackupCertt - $encBackupResults = Backup-DbaDatabase -SqlInstance $TestConfig.instance2 -Database master -EncryptionAlgorithm AES128 -EncryptionCertificate BackupCertt -BackupFileName 'encryptiontest.bak' -Description "Encrypted backup" - Invoke-Command2 -ComputerName $TestConfig.instance2 -ScriptBlock { Remove-Item -Path $args[0] } -ArgumentList $encBackupResults.FullName + Context "When testing backup encryption with certificate" { + BeforeEach { + $securePass = ConvertTo-SecureString "estBackupDir\master\script:instance1).split('\')[1])\Full\master-Full.bak" -AsPlainText -Force + New-DbaDbMasterKey -SqlInstance $TestConfig.instance2 -Database "Master" -SecurePassword $securePass -confirm:$false -ErrorAction SilentlyContinue + $cert = New-DbaDbCertificate -SqlInstance $TestConfig.instance2 -Database "master" -Name "BackupCertt" -Subject "BackupCertt" + $encBackupResults = Backup-DbaDatabase -SqlInstance $TestConfig.instance2 -Database "master" -EncryptionAlgorithm "AES128" -EncryptionCertificate "BackupCertt" -BackupFileName "encryptiontest.bak" -Description "Encrypted backup" + } It "Should encrypt the backup" { $encBackupResults.EncryptorType | Should Be "CERTIFICATE" $encBackupResults.KeyAlgorithm | Should Be "aes_128" } - Remove-DbaDbCertificate -SqlInstance $TestConfig.instance2 -Database master -Certificate BackupCertt -Confirm:$false - Remove-DbaDbMasterKey -SqlInstance $TestConfig.instance2 -Database Master -confirm:$false + AfterAll { + Remove-DbaDbCertificate -SqlInstance $TestConfig.instance2 -Database "master" -Certificate "BackupCertt" -Confirm:$false + Remove-DbaDbMasterKey -SqlInstance $TestConfig.instance2 -Database "Master" -confirm:$false + } } # Context "Test Backup Encryption with Asymmetric Key" { - # $key = New-DbaDbAsymmetricKey -SqlInstance $TestConfig.instance2 -Database master -Name BackupKey - # $encBackupResults = Backup-DbaDatabase -SqlInstance $TestConfig.instance2 -Database master -EncryptionAlgorithm AES128 -EncryptionKey BackupKey + # $key = New-DbaDbAsymmetricKey -SqlInstance $TestConfig.instance2 -Database "master" -Name "BackupKey" + # $encBackupResults = Backup-DbaDatabase -SqlInstance $TestConfig.instance2 -Database "master" -EncryptionAlgorithm "AES128" -EncryptionKey "BackupKey" # It "Should encrypt the backup" { # $encBackupResults.EncryptorType | Should Be "CERTIFICATE" # $encBackupResults.KeyAlgorithm | Should Be "aes_128" # } - # remove-DbaDbCertificate -SqlInstance $TestConfig.instance2 -Database master -Certificate BackupCertt -Confirm:$false + # remove-DbaDbCertificate -SqlInstance $TestConfig.instance2 -Database "master" -Certificate "BackupCertt" -Confirm:$false # } if ($env:azurepasswd) { - Context "Azure works" { + Context "When backing up to Azure" { BeforeAll { Get-DbaDatabase -SqlInstance $TestConfig.instance2 -Database "dbatoolsci_azure" | Remove-DbaDatabase -Confirm:$false $server = Connect-DbaInstance -SqlInstance $TestConfig.instance2 - if (Get-DbaCredential -SqlInstance $TestConfig.instance2 -Name "[$TestConfig.azureblob]" ) { + if (Get-DbaCredential -SqlInstance $TestConfig.instance2 -Name "[$TestConfig.azureblob]") { $sql = "DROP CREDENTIAL [$TestConfig.azureblob]" $server.Query($sql) } $sql = "CREATE CREDENTIAL [$TestConfig.azureblob] WITH IDENTITY = N'SHARED ACCESS SIGNATURE', SECRET = N'$env:azurepasswd'" $server.Query($sql) $server.Query("CREATE DATABASE dbatoolsci_azure") - if (Get-DbaCredential -SqlInstance $TestConfig.instance2 -name dbatools_ci) { + if (Get-DbaCredential -SqlInstance $TestConfig.instance2 -name "dbatools_ci") { $sql = "DROP CREDENTIAL dbatools_ci" $server.Query($sql) } @@ -385,16 +497,16 @@ go $server.Query("DROP CREDENTIAL [$TestConfig.azureblob]") } It "backs up to Azure properly using SHARED ACCESS SIGNATURE" { - $results = Backup-DbaDatabase -SqlInstance $TestConfig.instance2 -AzureBaseUrl $TestConfig.azureblob -Database dbatoolsci_azure -BackupFileName dbatoolsci_azure.bak -WithFormat - $results.Database | Should -Be 'dbatoolsci_azure' - $results.DeviceType | Should -Be 'URL' - $results.BackupFile | Should -Be 'dbatoolsci_azure.bak' + $results = Backup-DbaDatabase -SqlInstance $TestConfig.instance2 -AzureBaseUrl $TestConfig.azureblob -Database "dbatoolsci_azure" -BackupFileName "dbatoolsci_azure.bak" -WithFormat + $results.Database | Should -Be "dbatoolsci_azure" + $results.DeviceType | Should -Be "URL" + $results.BackupFile | Should -Be "dbatoolsci_azure.bak" } It "backs up to Azure properly using legacy credential" { - $results = Backup-DbaDatabase -SqlInstance $TestConfig.instance2 -AzureBaseUrl $TestConfig.azureblob -Database dbatoolsci_azure -BackupFileName dbatoolsci_azure2.bak -WithFormat -AzureCredential dbatools_ci - $results.Database | Should -Be 'dbatoolsci_azure' - $results.DeviceType | Should -Be 'URL' - $results.BackupFile | Should -Be 'dbatoolsci_azure2.bak' + $results = Backup-DbaDatabase -SqlInstance $TestConfig.instance2 -AzureBaseUrl $TestConfig.azureblob -Database "dbatoolsci_azure" -BackupFileName "dbatoolsci_azure2.bak" -WithFormat -AzureCredential "dbatools_ci" + $results.Database | Should -Be "dbatoolsci_azure" + $results.DeviceType | Should -Be "URL" + $results.BackupFile | Should -Be "dbatoolsci_azure2.bak" } } }