File: git-helpers.tests.ps1

package info (click to toggle)
python-azure 20251104%2Bgit-1
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 770,224 kB
  • sloc: python: 6,357,217; ansic: 804; javascript: 287; makefile: 198; sh: 193; xml: 109
file content (57 lines) | stat: -rw-r--r-- 1,872 bytes parent folder | download | duplicates (3)
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
52
53
54
55
56
57
# 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 ""
        }
    }
}