tests/dataconnection.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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
Get-Module Qlik-Cli | Remove-Module -Force Import-Module (Resolve-Path "$PSScriptRoot\..\Qlik-Cli.psm1").Path . (Resolve-Path "$PSScriptRoot\..\resources\dataconnection.ps1").Path Describe "Update-QlikDataConnection" { Mock Invoke-QlikPut -Verifiable { return ConvertFrom-Json $body } Mock Get-QlikDataConnection -ParameterFilter { $id -eq '158e743b-c59f-490e-900c-b57e66cf8185' } { return '{"id": "158e743b-c59f-490e-900c-b57e66cf8185", "username": "username", "connectionString": "C:\\Data"}' | ConvertFrom-Json } Context 'Password' { It 'should be updated when a credential is provided' { $password = ConvertTo-SecureString -String 'password' -AsPlainText -Force $credential = New-Object System.Management.Automation.PSCredential("username", $password) $dc = Update-QlikDataConnection ` -id '158e743b-c59f-490e-900c-b57e66cf8185' ` -Credential $credential $dc.password | Should Be 'password' Assert-VerifiableMock } } Context 'ConnectionString' { It 'should be updated when provided' { $dc = Update-QlikDataConnection ` -id '158e743b-c59f-490e-900c-b57e66cf8185' ` -connectionString 'C:\QlikSense' $dc.connectionString | Should Be 'C:\QlikSense' Assert-VerifiableMock } It 'should not change when parameter is not specified' { $dc = Update-QlikDataConnection ` -id '158e743b-c59f-490e-900c-b57e66cf8185' $dc.connectionString | Should Be 'C:\Data' Assert-VerifiableMock } } } |