Skip to content

Commit de8b6e4

Browse files
committed
possible fix for failing tests
1 parent d9feba7 commit de8b6e4

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

src/tests/Set-BloggerConfig.Tests.ps1

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,28 @@
22
Describe "Set-BloggerConfig" {
33
BeforeEach {
44
Import-Module $PSScriptRoot\..\PSBlogger.psm1 -Force
5+
6+
# Ensure the test has a clean BloggerSession variable
57
InModuleScope "PSBlogger" {
8+
# Remove the existing variable if it exists
9+
if (Get-Variable -Name BloggerSession -Scope Script -ErrorAction SilentlyContinue) {
10+
Remove-Variable -Name BloggerSession -Scope Script -Force
11+
}
12+
13+
# Create a new test-specific BloggerSession
614
$BloggerSession = [pscustomobject]@{
715
BlogId = $null
816
UserPreferences = "TestDrive:\UserPreferences.json"
917
}
18+
19+
# Set it as a script-scoped variable (same as the module does)
20+
New-Variable -Name BloggerSession -Value $BloggerSession -Scope Script -Force
1021
}
1122
}
1223

1324
It "Should persist new value to <UserPreference> to BloggerSession.UserPreferences" -TestCases @(
1425
@{ UserPreference="BlogId"; UserPreferenceValue="12345" }
1526
) {
16-
# arrange
17-
InModuleScope "PSBlogger" {
18-
$BloggerSession = [pscustomobject]@{
19-
BlogId = $null
20-
UserPreferences = "TestDrive:\UserPreferences.json"
21-
}
22-
}
2327

2428
# act
2529
Set-BloggerConfig -Name $UserPreference -Value $UserPreferenceValue -ErrorAction Stop

0 commit comments

Comments
 (0)