File tree Expand file tree Collapse file tree 4 files changed +87
-5
lines changed
Expand file tree Collapse file tree 4 files changed +87
-5
lines changed Original file line number Diff line number Diff line change 33
44# Rivet Changelog
55
6+ ## 0.21.0
7+
8+ > Released 24 May 2023
9+
10+ ### Changed
11+
12+ * Added an optional ` Database ` parameter to ` Connect-RivetSession ` function that allows specifying the default database
13+ to connect to when the Rivet session contains multiple databases.
14+
15+
616## 0.20.0
717
818> Released 19 May 2023
Original file line number Diff line number Diff line change @@ -4,15 +4,30 @@ function Connect-RivetSession
44 [CmdletBinding ()]
55 param (
66 [Parameter (Mandatory )]
7- [Rivet _Session ] $Session
7+ [Rivet _Session ] $Session ,
8+
9+ [String ] $Database
810 )
911
1012 Set-StrictMode - Version ' Latest'
1113 Use-CallerPreference - Cmdlet $PSCmdlet - SessionState $ExecutionContext.SessionState
1214
13- # We want the first database to be the default database.
14- for ($idx = $Session.Databases.Count - 1 ; $idx -ge 0 ; -- $idx )
15+ $databasesToConnect = & {
16+ if ( $Database )
17+ {
18+ $Database | Write-Output
19+ return
20+ }
21+
22+ # If no Database specified, we want the first database to be the default database.
23+ for ($idx = $Session.Databases.Count - 1 ; $idx -ge 0 ; -- $idx )
24+ {
25+ $Session.Databases [$idx ].Name | Write-Output
26+ }
27+ }
28+
29+ foreach ($db in $databasesToConnect )
1530 {
16- Connect-Database - Session $Session - Name $Session .Databases [ $idx ].Name
31+ Connect-Database - Session $Session - Name $db
1732 }
1833}
Original file line number Diff line number Diff line change 1111 RootModule = ' Rivet.psm1'
1212
1313 # Version number of this module.
14- ModuleVersion = ' 0.20 .0'
14+ ModuleVersion = ' 0.21 .0'
1515
1616 # ID used to uniquely identify this module
1717 GUID = ' 8af34b47-259b-4630-a945-75d38c33b94d'
Original file line number Diff line number Diff line change 1+
2+ # Requires -Version 5.1
3+ Set-StrictMode - Version ' Latest'
4+
5+ BeforeAll {
6+ & (Join-Path - Path $PSScriptRoot - ChildPath ' Initialize-Test.ps1' - Resolve)
7+
8+ function ThenNoErrors
9+ {
10+ $Global :Error | Should - BeNullOrEmpty
11+ }
12+
13+ function WhenConnectingRivet
14+ {
15+ param (
16+ [String ] $Database
17+ )
18+
19+ $params = @ { }
20+ if ( $Database )
21+ {
22+ $params [' Database' ] = $Database
23+ }
24+
25+ Connect-RivetSession - Session $RTSession @params
26+ }
27+ }
28+
29+ Describe ' Connect-RivetSession' {
30+ AfterEach {
31+ Stop-RivetTest
32+ }
33+
34+ It ' should connect to specified database when given' {
35+ Start-RivetTest - PhysicalDatabase @ ($RTDatabaseName , $RTDatabase2Name )
36+ $RTSession.Connection.Database | Should - Be $RTDatabaseName
37+ $RTSession.CurrentDatabase.Name | Should - Be $RTDatabaseName
38+
39+ WhenConnectingRivet - Database $RTDatabase2Name
40+ $RTSession.Connection.Database | Should - Be $RTDatabase2Name
41+ $RTSession.CurrentDatabase.Name | Should - Be $RTDatabase2Name
42+
43+ ThenNoErrors
44+ }
45+
46+ It ' should connect to the default database when no databases are given' {
47+ Start-RivetTest - PhysicalDatabase @ ($RTDatabaseName , $RTDatabase2Name )
48+ $RTSession.Connection.Database | Should - Be $RTDatabaseName
49+ $RTSession.CurrentDatabase.Name | Should - Be $RTDatabaseName
50+
51+ WhenConnectingRivet
52+ $RTSession.Connection.Database | Should - Be $RTDatabaseName
53+ $RTSession.CurrentDatabase.Name | Should - Be $RTDatabaseName
54+
55+ ThenNoErrors
56+ }
57+ }
You can’t perform that action at this time.
0 commit comments