tests/Get-DbaBackupHistory.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
Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan
Describe "Get-DbaBackupHistory Integration Tests" -Tags "Integrationtests" {
    
    Context "Setup removes, restores and backups on the local drive for Get-DbaBackupHistory" {
        $null = Get-DbaDatabase -SqlInstance localhost -NoSystemDb | Remove-DbaDatabase
        $null = Restore-DbaDatabase -SqlInstance localhost -Path C:\github\appveyor-lab\singlerestore\singlerestore.bak
        $db = Get-DbaDatabase -SqlInstance localhost -Database singlerestore
        $db | Backup-DbaDatabase -Type Full
        $db | Backup-DbaDatabase -Type Differential
        $db | Backup-DbaDatabase -Type Log
        $db | Backup-DbaDatabase -Type Log
        $null = Get-DbaDatabase -SqlInstance localhost -Database master | Backup-DbaDatabase -Type Full
    }
    
    <#
    Context "Get last history for single database" {
        $results = Get-DbaBackupHistory -SqlInstance localhost -Database singlerestore -Last
        It "Should be more than one database" {
            $results.count | Should Be 4
        }
    }
    #>

    
    Context "Get last history for all databases" {
        $results = Get-DbaBackupHistory -SqlInstance localhost
        It "Should be more than one database" {
            ($results | Where-Object Database -match "master").Count | Should BeGreaterThan 0
        }
    }
}