Functions/Convert-FileToBase64EncodedBytes.Tests.ps1
describe "BitTitan.Runbooks.Common/Convert-FileToBase64EncodedBytes" -Tag "module", "unit" { # Import the function to test . "$($PSScriptRoot)\Convert-FileToBase64EncodedBytes.ps1" it "converts the file contents to Base64 encoded bytes" { # Create the file $path = Join-Path $env:TEMP "$(New-Guid).txt" "Hello world!" | Set-Content -Path $path -NoNewline # Call the function $base64EncodedBytes = Convert-FileToBase64EncodedBytes -Path $path # Verify the result $base64EncodedBytes | Should Be "SGVsbG8gd29ybGQh" # Remove the file Remove-Item -Path $path -Force -Confirm:$false } it "returns null if the path does not exist" { # Call the function $base64EncodedBytes = Convert-FileToBase64EncodedBytes -Path (Join-Path $env:TEMP (New-Guid)) # Verify the result $base64EncodedBytes | Should BeNullOrEmpty } } |