Permalink
Browse files

check assertion works with snapshots

  • Loading branch information...
Rob Sewell Rob Sewell
Rob Sewell authored and Rob Sewell committed Feb 6, 2019
1 parent 4b52553 commit 1e3417283b5f6ff6cb0e9558ee2b06c3e46885b6
Showing with 26 additions and 2 deletions.
  1. +26 −2 tests/checks/DatabaseChecks.Tests.ps1
@@ -1,7 +1,7 @@
# load all of the assertion functions
. /../internal/assertions/Database.Assertions.ps1

Describe "Checking Database.Assertions.ps1 assertions" -Tag UnitTest, Assertions {
Describe "Checking Database.Assertions.ps1 assertions" -Tag UnitTest, Assertions, DatabaseAssertions {
Context "Testing Get-Database" {
It "Should have a Instance parameter" {
(Get-Command Get-Database).Parameters['Instance'] | Should -Not -BeNullOrEmpty -Because "We Need to pass the instance in"
@@ -112,11 +112,13 @@ Describe "Checking Database.Assertions.ps1 assertions" -Tag UnitTest, Assertions
Name = 'Dummy1';
ReadOnly = $False;
Status = 'Normal';
IsDatabaseSnapshot = $false;
},
[PSCustomObject]@{
Name = 'Dummy2';
ReadOnly = $True;
Status = 'Normal';
IsDatabaseSnapshot = $false;
}
);
}
@@ -127,6 +129,28 @@ Describe "Checking Database.Assertions.ps1 assertions" -Tag UnitTest, Assertions
It "It Should Not Fail for a database that is readonly when it is excluded" {
Assert-DatabaseStatus -Instance Dummy -ExcludeReadOnly 'Dummy2'
}
It "It Should Not Fail for a snapshots" {

Mock Connect-DbaInstance {
[PSCustomObject]@{
Databases = @(
[PSCustomObject]@{
Name = 'Dummy1';
ReadOnly = $False;
Status = 'Normal';
IsDatabaseSnapshot = $false;
},
[PSCustomObject]@{
Name = 'Dummy2';
ReadOnly = $True;
Status = 'Normal';
IsDatabaseSnapshot = $true;
}
);
}
}
Assert-DatabaseStatus -Instance Dummy
}
# Mock for offline failing
Mock Connect-DbaInstance {
[PSCustomObject]@{
@@ -303,7 +327,7 @@ Describe "Checking Database.Assertions.ps1 assertions" -Tag UnitTest, Assertions
It "Should call the Mocks successfully" {
$assertMockParams = @{
'CommandName' = 'Connect-DbaInstance'
'Times' = 14
'Times' = 15
'Exactly' = $true
}
Assert-MockCalled @assertMockParams

0 comments on commit 1e34172

Please sign in to comment.