Revised Powershell script testing
This commit is contained in:
@@ -27,7 +27,7 @@ function Test-ObsidianDownload {
|
|||||||
Write-Output "Simulating download failure..."
|
Write-Output "Simulating download failure..."
|
||||||
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings" -Name "ProxyEnable" -Value 1
|
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings" -Name "ProxyEnable" -Value 1
|
||||||
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings" -Name "ProxyServer" -Value "127.0.0.1:8080"
|
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings" -Name "ProxyServer" -Value "127.0.0.1:8080"
|
||||||
Start-Sleep -Seconds 5
|
Start-Sleep -Seconds 10 # Ensure proxy settings take effect
|
||||||
|
|
||||||
Write-Output "Downloading Obsidian installer..."
|
Write-Output "Downloading Obsidian installer..."
|
||||||
try {
|
try {
|
||||||
@@ -63,8 +63,59 @@ function Test-InvalidPluginConfig {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function Test-ObsidianInstallation {
|
||||||
|
Write-Output "Testing Obsidian installation..."
|
||||||
|
|
||||||
|
Write-Output "Installing Obsidian for Windows..."
|
||||||
|
if (-Not (Get-Command choco -ErrorAction SilentlyContinue)) {
|
||||||
|
Write-Output "Chocolatey is not installed. Installing Chocolatey..."
|
||||||
|
Set-ExecutionPolicy Bypass -Scope Process -Force;
|
||||||
|
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072;
|
||||||
|
$script = (New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')
|
||||||
|
Invoke-Command -ScriptBlock ([ScriptBlock]::Create($script))
|
||||||
|
}
|
||||||
|
choco install -y jq
|
||||||
|
|
||||||
|
Write-Output "Downloading Obsidian installer..."
|
||||||
|
Invoke-WebRequest -Uri "https://github.com/obsidianmd/obsidian-releases/releases/download/v1.6.3/Obsidian.1.6.3.exe" -OutFile "ObsidianInstaller.exe"
|
||||||
|
|
||||||
|
# Check if the installer was downloaded
|
||||||
|
if (Test-Path "ObsidianInstaller.exe") {
|
||||||
|
Write-Output "Running Obsidian installer..."
|
||||||
|
$startProcess = Start-Process -FilePath .\ObsidianInstaller.exe -ArgumentList "/S" -PassThru -Wait
|
||||||
|
Write-Output "Installer exit code: $($startProcess.ExitCode)"
|
||||||
|
|
||||||
|
# Check for Obsidian executable in possible installation paths
|
||||||
|
$obsidianPaths = @(
|
||||||
|
"C:\Program Files\Obsidian\Obsidian.exe",
|
||||||
|
"$env:LOCALAPPDATA\Programs\Obsidian\Obsidian.exe",
|
||||||
|
"$env:LOCALAPPDATA\Obsidian\Obsidian.exe"
|
||||||
|
)
|
||||||
|
|
||||||
|
$obsidianInstalled = $false
|
||||||
|
foreach ($path in $obsidianPaths) {
|
||||||
|
if (Test-Path $path) {
|
||||||
|
$obsidianInstalled = $true
|
||||||
|
Write-Output "Obsidian found at $path"
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($obsidianInstalled) {
|
||||||
|
Write-Output "Obsidian installed successfully."
|
||||||
|
} else {
|
||||||
|
Write-Output "Obsidian installation failed."
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Write-Output "Failed to download Obsidian installer."
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# Run tests
|
# Run tests
|
||||||
Test-AdminPrivilege
|
Test-AdminPrivilege
|
||||||
Test-ChocolateyInstallation
|
Test-ChocolateyInstallation
|
||||||
Test-ObsidianDownload
|
Test-ObsidianDownload
|
||||||
Test-InvalidPluginConfig
|
Test-InvalidPluginConfig
|
||||||
|
Test-ObsidianInstallation
|
||||||
|
|||||||
Reference in New Issue
Block a user