|
2 | 2 |
|
3 | 3 |
|
4 | 4 | Describe 'Parse-GitStatus' { |
5 | | - $file0 = "TestDrive:\file0" |
6 | | - $file1 = "TestDrive:\file1" |
7 | | - $file2 = "TestDrive:\spacey file2" |
8 | | - |
9 | | - New-Item $file0 |
10 | | - New-Item $file1 |
11 | | - New-Item $file2 |
12 | | - |
13 | | - # Setup/Cleanup crashed... |
14 | | - # BeforeEach { |
15 | | - # Push-Location "TestDrive:" |
16 | | - # New-Item $file0 |
17 | | - # New-Item $file1 |
18 | | - # } |
19 | | - |
20 | | - # AfterEach { |
21 | | - # Remove-Item $file0 |
22 | | - # Remove-Item $file1 |
23 | | - # Pop-Location |
24 | | - # } |
| 5 | + BeforeAll { |
| 6 | + New-Item "TestDrive:\file0" |
| 7 | + New-Item "TestDrive:\file1" |
| 8 | + New-Item "TestDrive:\spacey file2" |
| 9 | + } |
25 | 10 |
|
26 | 11 | It 'Can parse a modified file rename' { |
27 | | - Mock Invoke-Git { "RM $file0 -> $file2" } |
| 12 | + Mock Invoke-Git { "RM TestDrive:\file0 -> TestDrive:\spacey file2" } |
28 | 13 | $result = Parse-GitStatus |
29 | 14 |
|
30 | 15 | $result.Length | Should -Be 2 |
31 | | - $result[0].file | Should -Be "`"$file2`"" |
| 16 | + $result[0].file | Should -Be "`"TestDrive:\spacey file2`"" |
32 | 17 | $result[0].state | Should -Be "R" |
33 | | - $result[0].oldFile | Should -Be $file0 |
| 18 | + $result[0].oldFile | Should -Be "TestDrive:\file0" |
34 | 19 | $result[0].staged | Should -Be $true |
35 | 20 |
|
36 | | - $result[1].file | Should -Be "`"$file2`"" |
| 21 | + $result[1].file | Should -Be "`"TestDrive:\spacey file2`"" |
37 | 22 | $result[1].state | Should -Be "M" |
38 | 23 | $result[1].oldFile | Should -Be $null |
39 | 24 | $result[1].staged | Should -Be $false |
40 | 25 | } |
41 | 26 |
|
42 | 27 | It 'Add quotes around filename with spaces if it is not yet the case' { |
43 | | - Mock Invoke-Git { "?? $file2" } |
| 28 | + Mock Invoke-Git { "?? TestDrive:\spacey file2" } |
44 | 29 | $result = Parse-GitStatus |
45 | 30 |
|
46 | | - $result.relativePath | Should -Be "`"$file2`"" |
47 | | - $result.file | Should -Be "`"$file2`"" |
| 31 | + $result.relativePath | Should -Be "`"TestDrive:\spacey file2`"" |
| 32 | + $result.file | Should -Be "`"TestDrive:\spacey file2`"" |
48 | 33 |
|
49 | | - $fullPath = "`"$(Get-Location)\$file2`"" |
| 34 | + $fullPath = "`"$(Get-Location)\TestDrive:\spacey file2`"" |
50 | 35 | $result.fullPath | Should -Be $fullPath |
51 | 36 | } |
52 | 37 |
|
53 | 38 |
|
54 | 39 | It 'Passes extra CLI arguments along to git status' { |
55 | 40 | Mock Invoke-Git { |
56 | 41 | [string]$args | Should -BeLike "* -u" |
57 | | - " M $file0" |
| 42 | + " M TestDrive:\file0" |
58 | 43 | } |
59 | 44 |
|
60 | 45 | $result = Parse-GitStatus $false "-u" |
61 | 46 | } |
62 | 47 |
|
63 | 48 | It 'Parses a single modified file in working directory' { |
64 | | - Mock Invoke-Git { " M $file0" } |
| 49 | + Mock Invoke-Git { " M TestDrive:\file0" } |
65 | 50 | $result = Parse-GitStatus |
66 | 51 | $result.Length | Should -Be 1 |
67 | | - $result.file | Should -Be $file0 |
| 52 | + $result.file | Should -Be "TestDrive:\file0" |
68 | 53 | $result.staged | Should -Be $false |
69 | 54 | $result.state | Should -Be M |
70 | 55 | } |
71 | 56 |
|
72 | 57 | It 'Parses a single new file in working directory' { |
73 | | - Mock Invoke-Git { "?? $file0" } |
| 58 | + Mock Invoke-Git { "?? TestDrive:\file0" } |
74 | 59 | $result = Parse-GitStatus |
75 | 60 | $result.Length | Should -Be 1 |
76 | | - $result.file | Should -Be $file0 |
| 61 | + $result.file | Should -Be "TestDrive:\file0" |
77 | 62 | $result.staged | Should -Be $false |
78 | 63 | $result.state | Should -Be A |
79 | 64 | } |
80 | 65 |
|
81 | 66 | It 'Parses a single modified file in staging area' { |
82 | | - Mock Invoke-Git { "M $file0" } |
| 67 | + Mock Invoke-Git { "M TestDrive:\file0" } |
83 | 68 | $result = Parse-GitStatus |
84 | 69 | $result.Length | Should -Be 1 |
85 | | - $result.file | Should -Be $file0 |
| 70 | + $result.file | Should -Be "TestDrive:\file0" |
86 | 71 | $result.staged | Should -Be $true |
87 | 72 | $result.state | Should -Be M |
88 | 73 | } |
89 | 74 |
|
90 | 75 | It 'Parses a single new file in staging area' { |
91 | | - Mock Invoke-Git { "A $file0" } |
| 76 | + Mock Invoke-Git { "A TestDrive:\file0" } |
92 | 77 | $result = Parse-GitStatus |
93 | 78 | $result.Length | Should -Be 1 |
94 | | - $result.file | Should -Be $file0 |
| 79 | + $result.file | Should -Be "TestDrive:\file0" |
95 | 80 | $result.staged | Should -Be $true |
96 | 81 | $result.state | Should -Be A |
97 | 82 | } |
98 | 83 |
|
99 | 84 | It 'Parses a single modified file in staging area AND working directory' { |
100 | | - Mock Invoke-Git { "MM $file0" } |
| 85 | + Mock Invoke-Git { "MM TestDrive:\file0" } |
101 | 86 | $result = Parse-GitStatus |
102 | 87 |
|
103 | 88 | $result.Length | Should -Be 2 |
104 | 89 |
|
105 | | - $result[0].file | Should -Be $file0 |
| 90 | + $result[0].file | Should -Be "TestDrive:\file0" |
106 | 91 | $result[0].staged | Should -Be $true |
107 | 92 | $result[0].state | Should -Be M |
108 | 93 |
|
109 | | - $result[1].file | Should -Be $file0 |
| 94 | + $result[1].file | Should -Be "TestDrive:\file0" |
110 | 95 | $result[1].staged | Should -Be $false |
111 | 96 | $result[1].state | Should -Be M |
112 | 97 | } |
113 | 98 |
|
114 | 99 | It 'Parses multiple files' { |
115 | | - Mock Invoke-Git { "M $file0"," D $file1" } |
| 100 | + Mock Invoke-Git { "M TestDrive:\file0"," D TestDrive:\file1" } |
116 | 101 | $result = Parse-GitStatus |
117 | 102 |
|
118 | 103 | $result.Length | Should -Be 2 |
119 | 104 |
|
120 | | - $result[0].file | Should -Be $file0 |
| 105 | + $result[0].file | Should -Be "TestDrive:\file0" |
121 | 106 | $result[0].staged | Should -Be $true |
122 | 107 | $result[0].state | Should -Be M |
123 | 108 |
|
124 | | - $result[1].file | Should -Be $file1 |
| 109 | + $result[1].file | Should -Be "TestDrive:\file1" |
125 | 110 | $result[1].staged | Should -Be $false |
126 | 111 | $result[1].state | Should -Be D |
127 | 112 | } |
|
0 commit comments