Skip to content

Commit

Permalink
Add Powershell Tests for VBS scripts
Browse files Browse the repository at this point in the history
Signed-off-by: SONIABHISHEK121 <[email protected]>
  • Loading branch information
ABHISHEKSONI121 committed Aug 1, 2024
1 parent 90ef00f commit 4bc7c2b
Show file tree
Hide file tree
Showing 5 changed files with 157 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/windows-installer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,18 @@ jobs:
run: |
$env:Path += ";$pwd"
. .\tests\test_rece1.ps1
- name: Test pyi25.vbs
run: |
.\tests\test_pyi25.ps1
- name: Test pyqr.vbs
run: |
.\tests\test_pyqr.ps1
- name: Test factura_electronica.vbs
run: |
.\tests\test_factura_electronica.ps1
- name: Test remito_electronico_carnico.vbs
run: |
.\tests\test_remito_electronico_carnico.ps1
pre-release:
name: "Pre Release"
Expand Down
49 changes: 49 additions & 0 deletions tests/powershell/test_factura_electronica.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# test_factura_electronica.ps1

$ErrorActionPreference = "Stop"

# Run the VBS script and capture its output
$output = cscript //nologo ejemplos\factura_electronica.vbs

# Check if the script executed successfully
if ($LASTEXITCODE -ne 0) {
Write-Error "factura_electronica.vbs failed to execute"
exit 1
}

# Test for expected output
$expectedOutputs = @(
"InstallDir",
"Token",
"Sign",
"Ultimo comprobante:",
"Resultado",
"CAE",
"Numero de comprobante:",
"ErrMsg",
"Obs",
"Reprocesar:",
"Reproceso:",
"EmisionTipo:"
)

foreach ($expected in $expectedOutputs) {
if ($output -notmatch $expected) {
Write-Error "Expected output not found: $expected"
exit 1
}
}

# Check for successful CAE solicitation
if ($output -notmatch "CAE: \d+") {
Write-Error "CAE not obtained successfully"
exit 1
}

# Check for successful result
if ($output -notmatch "Resultado: A") {
Write-Error "Invoice authorization not successful"
exit 1
}

Write-Host "All tests for factura_electronica.vbs passed successfully"
Empty file added tests/powershell/test_pyi25.ps1
Empty file.
40 changes: 40 additions & 0 deletions tests/powershell/test_pyqr.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# test_pyqr.ps1

$ErrorActionPreference = "Stop"

# Run the VBS script and capture its output
$output = cscript //nologo ejemplos\pyqr\pyqr.vbs

# Check if the script executed successfully
if ($LASTEXITCODE -ne 0) {
Write-Error "pyqr.vbs failed to execute"
exit 1
}

# Test for expected output
if ($output -notmatch "CrearArchivo") {
Write-Error "CrearArchivo output not found"
exit 1
}

if ($output -notmatch "GenerarImagen") {
Write-Error "GenerarImagen output not found"
exit 1
}

# Extract the file paths from the output
$createdFile = ($output -split "`n" | Select-String "CrearArchivo").ToString().Trim()
$generatedImage = ($output -split "`n" | Select-String "GenerarImagen").ToString().Trim()

# Check if the files were created
if (-not (Test-Path $createdFile)) {
Write-Error "Created file does not exist: $createdFile"
exit 1
}

if (-not (Test-Path $generatedImage)) {
Write-Error "Generated image does not exist: $generatedImage"
exit 1
}

Write-Host "All tests for pyqr.vbs passed successfully"
56 changes: 56 additions & 0 deletions tests/powershell/test_remito_electronico_carnico.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# test_remito_electronico_carnico.ps1

$ErrorActionPreference = "Stop"

# Run the VBS script and capture its output
$output = cscript //nologo ejemplos\remito_electronico_carnico.vbs

# Check if the script executed successfully
if ($LASTEXITCODE -ne 0) {
Write-Error "remito_electronico_carnico.vbs failed to execute"
exit 1
}

# Test for expected output
$expectedOutputs = @(
"InstallDir",
"Token",
"Sign",
"Ultimo comprobante:",
"Resultado:",
"Cod Remito:",
"Numero Remito:",
"Cod Autorizacion:",
"Fecha Emision",
"Fecha Vencimiento",
"Observaciones:",
"Errores:",
"Evento:"
)

foreach ($expected in $expectedOutputs) {
if ($output -notmatch $expected) {
Write-Error "Expected output not found: $expected"
exit 1
}
}

# Check for successful remito generation
if ($output -notmatch "Resultado: A") {
Write-Error "Remito generation not successful"
exit 1
}

# Check for Cod Remito
if ($output -notmatch "Cod Remito: \d+") {
Write-Error "Cod Remito not obtained successfully"
exit 1
}

# Check if QR file was created
if (-not (Test-Path "qr.png")) {
Write-Error "QR code image file was not created"
exit 1
}

Write-Host "All tests for remito_electronico_carnico.vbs passed successfully"

0 comments on commit 4bc7c2b

Please sign in to comment.