* Add ConflictedFile to git-helpers.ps1, add git-helpers.tests.ps1 to exercise basic functionality. * Add `resolve-asset-conflict.ps1` a script that can autoresolve an assets.json file. --------- Co-authored-by: Scott Beddall (from Dev Box) <scbedd@microsoft.com> Co-authored-by: Scott Beddall <45376673+scbedd@users.noreply.github.com> Co-authored-by: Ben Broderick Phillips <bebroder@microsoft.com>
57 lines
1.8 KiB
PowerShell
57 lines
1.8 KiB
PowerShell
# Install-Module -Name Pester -Force -SkipPublisherCheck
|
|
# Invoke-Pester -Passthru path/to/git-helpers.tests.ps1
|
|
BeforeAll {
|
|
. $PSScriptRoot/git-helpers.ps1
|
|
|
|
$RunFolder = "$PSScriptRoot/.testruns"
|
|
|
|
if (Test-Path $RunFolder){
|
|
Remove-Item -Recurse -Force $RunFolder
|
|
}
|
|
|
|
New-Item -ItemType Directory -Path $RunFolder
|
|
}
|
|
|
|
Describe "git-helpers.ps1 tests"{
|
|
Context "Test Parse-ConflictedFile" {
|
|
It "Parses a basic conflicted file" {
|
|
$content = @'
|
|
{
|
|
"AssetsRepo": "Azure/azure-sdk-assets-integration",
|
|
"AssetsRepoPrefixPath": "python",
|
|
"TagPrefix": "python/storage/azure-storage-blob",
|
|
<<<<<<< HEAD
|
|
"Tag": "integration/example/storage_feature_addition2"
|
|
=======
|
|
"Tag": "integration/example/storage_feature_addition1"
|
|
>>>>>>> test-storage-tag-combination
|
|
}
|
|
'@
|
|
$contentPath = Join-Path $RunFolder "basic_conflict_test.json"
|
|
Set-Content -Path $contentPath -Value $content
|
|
|
|
$resolution = [ConflictedFile]::new($contentPath)
|
|
$resolution.IsConflicted | Should -Be $true
|
|
$resolution.LeftSource | Should -Be "HEAD"
|
|
$resolution.RightSource | Should -Be "test-storage-tag-combination"
|
|
}
|
|
|
|
It "Recognizes when no conflicts are present" {
|
|
$content = @'
|
|
{
|
|
"AssetsRepo": "Azure/azure-sdk-assets-integration",
|
|
"AssetsRepoPrefixPath": "python",
|
|
"TagPrefix": "python/storage/azure-storage-blob",
|
|
"Tag": "integration/example/storage_feature_addition1"
|
|
}
|
|
'@
|
|
$contentPath = Join-Path $RunFolder "no_conflict_test.json"
|
|
Set-Content -Path $contentPath -Value $content
|
|
|
|
$resolution = [ConflictedFile]::new($contentPath)
|
|
$resolution.IsConflicted | Should -Be $false
|
|
$resolution.LeftSource | Should -Be ""
|
|
$resolution.RightSource | Should -Be ""
|
|
}
|
|
}
|
|
} |