@@ -24,6 +24,17 @@ Describe 'Get-GitStatus Tests' {
24
24
$status = Get-GitStatus
25
25
Should - Invoke - ModuleName posh- git - CommandName git - Exactly 1
26
26
$status.Branch | Should - Be " rkeithill/more-status-tests"
27
+ $status.HasIndex | Should - Be $false
28
+ $status.HasUntracked | Should - Be $false
29
+ $status.HasWorking | Should - Be $false
30
+ $status.Working.Added.Count | Should - Be 0
31
+ $status.Working.Deleted.Count | Should - Be 0
32
+ $status.Working.Modified.Count | Should - Be 0
33
+ $status.Working.Unmerged.Count | Should - Be 0
34
+ $status.Index.Added.Count | Should - Be 0
35
+ $status.Index.Deleted.Count | Should - Be 0
36
+ $status.Index.Modified.Count | Should - Be 0
37
+ $status.Index.Unmerged.Count | Should - Be 0
27
38
}
28
39
29
40
@@ -428,4 +439,73 @@ U test/Unmerged.Tests.ps1
428
439
$status.Index.Unmerged [0 ] | Should - Be " test/Unmerged.Tests.ps1"
429
440
}
430
441
}
442
+
443
+ Context ' In .git' {
444
+ BeforeEach {
445
+ [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute (' PSUseDeclaredVarsMoreThanAssigments' , ' ' )]
446
+ $repoPath = NewGitTempRepo
447
+ }
448
+ AfterEach {
449
+ Set-Location $PSScriptRoot
450
+ RemoveGitTempRepo $repoPath
451
+ }
452
+
453
+ It(' Does not have files' ) {
454
+ New-Item " $repoPath /test.txt" - ItemType File
455
+
456
+ $status = Get-GitStatus
457
+ $status.HasUntracked | Should - Be $true
458
+ $status.HasWorking | Should - Be $true
459
+ $status.Working.Added.Count | Should - Be 1
460
+
461
+ Set-Location " $repoPath /.git" - ErrorAction Stop
462
+
463
+ $status = Get-GitStatus
464
+ $status.HasUntracked | Should - Be $false
465
+ $status.HasWorking | Should - Be $false
466
+ $status.Working.Added.Count | Should - Be 0
467
+
468
+ Set-Location " $repoPath /.git/refs" - ErrorAction Stop
469
+
470
+ $status = Get-GitStatus
471
+ $status.HasUntracked | Should - Be $false
472
+ $status.HasWorking | Should - Be $false
473
+ $status.Working.Added.Count | Should - Be 0
474
+ }
475
+ }
476
+
477
+ Context ' In .github' {
478
+ BeforeEach {
479
+ [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute (' PSUseDeclaredVarsMoreThanAssigments' , ' ' )]
480
+ $repoPath = NewGitTempRepo
481
+ New-Item - Type Directory - Force " $repoPath /.github/workflows"
482
+ }
483
+ AfterEach {
484
+ Set-Location $PSScriptRoot
485
+ RemoveGitTempRepo $repoPath
486
+ }
487
+
488
+ It(' Files are not ignored' ) {
489
+ New-Item " $repoPath /test.txt" - ItemType File
490
+
491
+ $status = Get-GitStatus
492
+ $status.HasUntracked | Should - Be $true
493
+ $status.HasWorking | Should - Be $true
494
+ $status.Working.Added.Count | Should - Be 1
495
+
496
+ Set-Location " $repoPath /.github" - ErrorAction Stop
497
+
498
+ $status = Get-GitStatus
499
+ $status.HasUntracked | Should - Be $true
500
+ $status.HasWorking | Should - Be $true
501
+ $status.Working.Added.Count | Should - Be 1
502
+
503
+ Set-Location " $repoPath /.github/workflows" - ErrorAction Stop
504
+
505
+ $status = Get-GitStatus
506
+ $status.HasUntracked | Should - Be $true
507
+ $status.HasWorking | Should - Be $true
508
+ $status.Working.Added.Count | Should - Be 1
509
+ }
510
+ }
431
511
}
0 commit comments