-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-wrapper.ps1
More file actions
121 lines (104 loc) · 4.72 KB
/
test-wrapper.ps1
File metadata and controls
121 lines (104 loc) · 4.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# Test script to verify the wheels wrapper logic without actually installing
Write-Host "Testing Wheels CLI Wrapper Logic" -ForegroundColor Green
Write-Host "=================================" -ForegroundColor Green
Write-Host ""
# Test 1: Check if script handles missing CommandBox
Write-Host "Test 1: Without CommandBox installed" -ForegroundColor Yellow
Write-Host "-------------------------------------" -ForegroundColor Yellow
# Simulate the check for CommandBox
$commandboxInstalled = $false
try {
$commandboxPath = Get-Command box -ErrorAction SilentlyContinue
if ($commandboxPath) {
$commandboxInstalled = $true
}
} catch {
# CommandBox not found
}
if (-not $commandboxInstalled) {
Write-Host "[PASS] CommandBox not found (as expected)" -ForegroundColor Green
Write-Host " Script would check CommandBox dependency" -ForegroundColor Cyan
} else {
Write-Host "[FAIL] CommandBox found (unexpected for this test)" -ForegroundColor Red
}
Write-Host ""
# Test 2: Verify wrapper script exists and has correct content
Write-Host "Test 2: Verify wrapper script" -ForegroundColor Yellow
Write-Host "------------------------------" -ForegroundColor Yellow
$wrapperPath = Join-Path $PSScriptRoot "tools\wheels.cmd"
if (Test-Path $wrapperPath) {
Write-Host "[PASS] wheels.cmd exists" -ForegroundColor Green
# Check key components of the script
$content = Get-Content $wrapperPath -Raw
$checks = @(
@{Name="CommandBox check"; Pattern="where box"},
@{Name="Wheels CLI auto-install"; Pattern="box install wheels-cli"},
@{Name="Help handler"; Pattern=":show_help"},
@{Name="Version handler"; Pattern=":show_version"},
@{Name="Argument conversion"; Pattern="converted_args"},
@{Name="Execute command"; Pattern="box wheels"}
)
foreach ($check in $checks) {
if ($content -like "*$($check.Pattern)*") {
Write-Host " [PASS] $($check.Name)" -ForegroundColor Green
} else {
Write-Host " [FAIL] $($check.Name)" -ForegroundColor Red
}
}
} else {
Write-Host "[FAIL] wheels.cmd not found" -ForegroundColor Red
}
Write-Host ""
# Test 3: Test argument conversion logic
Write-Host "Test 3: Argument conversion examples" -ForegroundColor Yellow
Write-Host "------------------------------------" -ForegroundColor Yellow
$testCases = @(
@{Input="--help"; Expected="Would show help"},
@{Input="--version"; Expected="Would show version"},
@{Input="generate model User"; Expected="generate model User"},
@{Input="--template=default"; Expected="template=default"},
@{Input="--force"; Expected="force=true"},
@{Input="--noBackup"; Expected="backup=false"}
)
Write-Host "Input arguments -> Expected conversion:" -ForegroundColor Cyan
foreach ($test in $testCases) {
Write-Host " '$($test.Input)' -> '$($test.Expected)'" -ForegroundColor Gray
}
Write-Host ""
# Test 4: Installation script logic
Write-Host "Test 4: Installation script features" -ForegroundColor Yellow
Write-Host "------------------------------------" -ForegroundColor Yellow
$installScript = Join-Path $PSScriptRoot "tools\chocolateyinstall.ps1"
if (Test-Path $installScript) {
$installContent = Get-Content $installScript -Raw
$features = @(
@{Name="CommandBox detection"; Pattern="Get-Command box"},
@{Name="CommandBox dependency check"; Pattern="CommandBox dependency"},
@{Name="Environment refresh"; Pattern="Update-SessionEnvironment"},
@{Name="Create wrapper script"; Pattern="wheels.cmd"},
@{Name="Install bin shim"; Pattern="Install-BinFile"}
)
foreach ($feature in $features) {
if ($installContent -like "*$($feature.Pattern)*") {
Write-Host "[PASS] $($feature.Name)" -ForegroundColor Green
} else {
Write-Host "[FAIL] $($feature.Name)" -ForegroundColor Red
}
}
} else {
Write-Host "[FAIL] chocolateyinstall.ps1 not found" -ForegroundColor Red
}
Write-Host ""
# Summary
Write-Host "Test Summary" -ForegroundColor Green
Write-Host "============" -ForegroundColor Green
Write-Host "The wheels wrapper package structure is correct." -ForegroundColor Green
Write-Host ""
Write-Host "Key features:" -ForegroundColor Yellow
Write-Host "- Automatically installs CommandBox if not present" -ForegroundColor Cyan
Write-Host "- Creates wheels.cmd wrapper for Windows" -ForegroundColor Cyan
Write-Host "- Converts CLI arguments to CommandBox format" -ForegroundColor Cyan
Write-Host "- Auto-installs Wheels CLI on first use" -ForegroundColor Cyan
Write-Host "- Provides --help and --version support" -ForegroundColor Cyan
Write-Host ""
Write-Host "Note: Full installation requires admin privileges for Chocolatey." -ForegroundColor Yellow