Tests/updateLocalDevBranch.Tests.ps1

$updateLocalDevBranchScript = Resolve-Path (Join-Path $PSScriptRoot ..\updateLocalDevBranch.ps1)
describe "test config is altered for localdev" {
    context "the databrickspath is updated" {
        it "Script will not throw. " {
            $testConfig = [PSCustomObject]@{
                dataBricksPath    = '/Users/__email__/__branch__'
            }
            {$actualConfig = & $updateLocalDevBranchScript -config $testConfig} | Should -Not -Throw
        }
        it "Branch is updated to current git branch " {
            $testConfig = [PSCustomObject]@{
                dataBricksPath    = '/Users/__email__/__branch__'
            }
            $expectedBranchName = &git rev-parse --abbrev-ref HEAD
            $expectedDataBricksPath = "/Users/__email__/$($expectedBranchName)"
            $actualConfig = & $updateLocalDevBranchScript -config $testConfig
            $actualConfig.dataBricksPath | Should -Be $expectedDataBricksPath
        }
        it "Branch is updated to named branch " {
            $testConfig = [PSCustomObject]@{
                dataBricksPath    = '/Users/__email__/__branch__'
            }
            $BranchName = "bob"
            $expectedDataBricksPath = "/Users/__email__/$($branchName)"
            $actualConfig = & $updateLocalDevBranchScript -config $testConfig -branch $BranchName
            $actualConfig.dataBricksPath | Should -Be $expectedDataBricksPath
        }
    }
}