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

SqlDatabaseRole: Add a test to check error message on helper function #1626

Merged
merged 1 commit into from
Oct 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- SqlEndpoint
- Added support for the Service Broker Endpoint ([issue #498](https://github.com/dsccommunity/SqlServerDsc/issues/498)).
- SqlDatabaseRole
- Added test to ensure Add-SqlDscDatabaseRoleMember throws the expected error
([issue #1620](https://github.com/dsccommunity/SqlServerDsc/issues/1620)).

### Changed

Expand Down
26 changes: 25 additions & 1 deletion tests/Unit/DSC_SqlDatabaseRole.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ try
} -PassThru
))
}
}-PassThru -Force
} -PassThru -Force
))
}
} -PassThru -Force |
Expand Down Expand Up @@ -1108,6 +1108,30 @@ try

Assert-VerifiableMock
}

Describe 'Add-SqlDscDatabaseRoleMember' -Tag 'Helper' {
BeforeAll {
$mockSqlDatabaseObject = @{
Name = $mockSqlDatabaseName
Roles = @{
$mockSqlDatabaseRole1 = 'Role'
}
Users = @{
$mockSqlServerLogin1 = 'User'
}
}
$mockName = 'MissingRole'
$mockMemberName = 'MissingUser'

}
Context 'When calling with a role that does not exist' {
It 'Should throw the correct error' {
{
Add-SqlDscDatabaseRoleMember -SqlDatabaseObject $mockSqlDatabaseObject -Name $mockName -MemberName $mockMemberName
} | Should -Throw ($script:localizedData.DatabaseRoleOrUserNotFound -f $mockName, $mockMemberName, $mockSqlDatabaseName)
}
}
}
}
}
finally
Expand Down