Skip to content

Commit b51cca0

Browse files
chcurlet-msftclaude
andcommitted
Fix tests: wrap private function tests in InModuleScope
Private functions are not accessible outside module scope. Tests for private functions now use InModuleScope to access them properly. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 66c7969 commit b51cca0

File tree

1 file changed

+33
-31
lines changed

1 file changed

+33
-31
lines changed

Tests/ReFSSnapshots.Tests.ps1

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -321,47 +321,48 @@ Describe "Compare-RefsSnapshot" {
321321
}
322322

323323
Describe "Private Functions" {
324-
Context "Test-RefsVolume" {
325-
It "Should return false for non-ReFS paths" {
326-
if (Test-Path TestDrive:\) {
327-
Test-RefsVolume -Path "TestDrive:\" | Should -Be $false
324+
InModuleScope ReFSSnapshots {
325+
Context "Test-RefsVolume" {
326+
It "Should return false for non-ReFS paths" {
327+
if (Test-Path TestDrive:\) {
328+
Test-RefsVolume -Path "TestDrive:\" | Should -Be $false
329+
}
328330
}
329-
}
330331

331-
It "Should handle absolute paths correctly" {
332-
# Regression test for path resolution bug where absolute paths were treated as relative
333-
if (Test-Path C:\) {
334-
# Should not throw even when called from different working directory
335-
{ Test-RefsVolume -Path "C:\Windows" } | Should -Not -Throw
332+
It "Should handle absolute paths correctly" {
333+
# Regression test for path resolution bug where absolute paths were treated as relative
334+
if (Test-Path C:\) {
335+
# Should not throw even when called from different working directory
336+
{ Test-RefsVolume -Path "C:\Windows" } | Should -Not -Throw
337+
}
336338
}
337-
}
338339

339-
It "Should handle paths with spaces" {
340-
# Test that paths with spaces are handled correctly
341-
$testPath = "C:\Program Files"
342-
if (Test-Path $testPath) {
343-
{ Test-RefsVolume -Path $testPath } | Should -Not -Throw
340+
It "Should handle paths with spaces" {
341+
# Test that paths with spaces are handled correctly
342+
$testPath = "C:\Program Files"
343+
if (Test-Path $testPath) {
344+
{ Test-RefsVolume -Path $testPath } | Should -Not -Throw
345+
}
344346
}
345347
}
346-
}
347348

348-
Context "Invoke-RefsUtilStreamSnapshot" {
349-
It "Should validate Operation parameter" {
350-
$param = (Get-Command Invoke-RefsUtilStreamSnapshot).Parameters['Operation']
351-
$param.Attributes.ValidValues | Should -Contain 'Create'
352-
$param.Attributes.ValidValues | Should -Contain 'List'
353-
$param.Attributes.ValidValues | Should -Contain 'Delete'
354-
$param.Attributes.ValidValues | Should -Contain 'Query'
355-
}
349+
Context "Invoke-RefsUtilStreamSnapshot" {
350+
It "Should validate Operation parameter" {
351+
$param = (Get-Command Invoke-RefsUtilStreamSnapshot).Parameters['Operation']
352+
$param.Attributes.ValidValues | Should -Contain 'Create'
353+
$param.Attributes.ValidValues | Should -Contain 'List'
354+
$param.Attributes.ValidValues | Should -Contain 'Delete'
355+
$param.Attributes.ValidValues | Should -Contain 'Query'
356+
}
356357

357-
It "Should return result with Success, Output, and Error properties" {
358-
# Regression test for error handling - ensure result object structure is correct
359-
$param = (Get-Command Invoke-RefsUtilStreamSnapshot)
360-
$param | Should -Not -BeNullOrEmpty
358+
It "Should return result with Success, Output, and Error properties" {
359+
# Regression test for error handling - ensure result object structure is correct
360+
$param = (Get-Command Invoke-RefsUtilStreamSnapshot)
361+
$param | Should -Not -BeNullOrEmpty
362+
}
361363
}
362-
}
363364

364-
Context "ConvertFrom-RefsUtilOutput" {
365+
Context "ConvertFrom-RefsUtilOutput" {
365366
It "Should parse list output correctly" {
366367
$output = "Snapshot1`nSnapshot2`nSnapshot3"
367368
$result = ConvertFrom-RefsUtilOutput -Output $output -Operation List
@@ -423,6 +424,7 @@ Describe "Private Functions" {
423424
$result | Should -BeNullOrEmpty
424425
}
425426
}
427+
}
426428
}
427429

428430
Describe "Integration Tests" -Skip {

0 commit comments

Comments
 (0)