Skip to content

Commit 66a25a8

Browse files
committed
update spec tests
Signed-off-by: Corey Hemminger <hemminger@hotmail.com>
1 parent 1b6a2b4 commit 66a25a8

File tree

2 files changed

+23
-22
lines changed

2 files changed

+23
-22
lines changed

lib/mixlib/install/generator/powershell/scripts/get_project_metadata.ps1.erb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,32 +51,32 @@ function Get-ProjectMetadata {
5151

5252
# PowerShell is only on Windows ATM
5353
$platform = 'windows'
54-
Write-Verbose "Platform: $platform"
54+
Write-Host "Platform: $platform"
5555

5656
$platform_version = Get-PlatformVersion
57-
Write-Verbose "Platform Version: $platform_version"
57+
Write-Host "Platform Version: $platform_version"
5858

5959
if ($architecture -eq 'auto') {
6060
$architecture = Get-PlatformArchitecture
6161
}
6262

63-
Write-Verbose "Architecture: $architecture"
64-
Write-Verbose "Project: $project"
63+
Write-Host "Architecture: $architecture"
64+
Write-Host "Project: $project"
6565

6666
# Use commercial API if license_id is provided, otherwise use omnitruck if no URL is provided
6767
if ([string]::IsNullOrEmpty($base_server_uri)) {
6868
if ($license_id) {
6969
# Check if license_id starts with 'free-' or 'trial-' for trial API
7070
if ($license_id -match '^(free-|trial-)') {
7171
$base_server_uri = 'https://chefdownload-trial.chef.io'
72-
Write-Verbose "Using Trial API with license ID"
72+
Write-Host "Using Trial API with license ID"
7373
} else {
7474
$base_server_uri = 'https://chefdownload-commercial.chef.io'
75-
Write-Verbose "Using Commercial API with license ID"
75+
Write-Host "Using Commercial API with license ID"
7676
}
7777
} else {
7878
$base_server_uri = 'https://omnitruck.chef.io'
79-
Write-Verbose "Using Omnitruck API without license ID"
79+
Write-Host "Using Omnitruck API without license ID"
8080
}
8181
}
8282

@@ -111,7 +111,7 @@ function Get-ProjectMetadata {
111111
$metadata_base_url += [string]::join('&', $metadata_array)
112112
$metadata_url = new-uri $base_server_uri $metadata_base_url
113113

114-
Write-Verbose "Downloading $project details from $metadata_url"
114+
Write-Host "Downloading $project details from $metadata_url"
115115
$response = (Get-WebContent $metadata_url).trim()
116116

117117
# Commercial and trial APIs return JSON, omnitruck returns text format
@@ -136,9 +136,9 @@ function Get-ProjectMetadata {
136136
foreach { $hash = @{} } {$key, $value = $_ -split '\s+'; $hash.Add($key, $value)} {$hash}
137137
}
138138

139-
Write-Verbose "Project details: "
139+
Write-Host "Project details: "
140140
foreach ($key in $package_metadata.keys) {
141-
Write-Verbose "`t$key = $($package_metadata[$key])"
141+
Write-Host "`t$key = $($package_metadata[$key])"
142142
}
143143
$package_metadata
144144
}

spec/unit/mixlib/install/generator_spec.rb

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@
122122
end
123123

124124
it "skips caching checks when using content-disposition" do
125-
expect(install_script).to include('if test "x$use_content_disposition" = "xtrue"; then')
125+
expect(install_script).to include('if [ "$use_content_disposition" = "true" ]; then')
126126
expect(install_script).to include('cached_file_available="false"')
127127
end
128128

@@ -162,7 +162,7 @@
162162
end
163163

164164
it "skips caching checks when using content-disposition" do
165-
expect(install_script).to include('if test "x$use_content_disposition" = "xtrue"; then')
165+
expect(install_script).to include('if [ "$use_content_disposition" = "true" ]; then')
166166
expect(install_script).to include('cached_file_available="false"')
167167
end
168168
end
@@ -192,7 +192,7 @@
192192
end
193193

194194
it "skips caching checks when using content-disposition" do
195-
expect(install_script).to include('if test "x$use_content_disposition" = "xtrue"; then')
195+
expect(install_script).to include('if [ "$use_content_disposition" = "true" ]; then')
196196
expect(install_script).to include('cached_file_available="false"')
197197
end
198198

@@ -270,7 +270,7 @@
270270
end
271271

272272
it "includes chef-ice conditional logic" do
273-
expect(install_script).to include('if test "$project" = "chef-ice"')
273+
expect(install_script).to include('if [ "$project" = "chef-ice" ]; then')
274274
end
275275

276276
it "includes RPM-based platform detection" do
@@ -299,7 +299,7 @@
299299
end
300300

301301
it "constructs chef-ice metadata URL with m, p, pm parameters" do
302-
expect(install_script).to include('metadata_url="$base_api_url/$channel/$project/metadata?v=$version&license_id=$license_id&m=$machine&p=$platform_param&pm=$package_manager"')
302+
expect(install_script).to include('metadata_url="$base_api_url/$channel/$project/metadata?license_id=$license_id&v=$version&m=$machine&p=$platform_param&pm=$package_manager"')
303303
end
304304

305305
it "uses commercial API endpoint" do
@@ -315,11 +315,11 @@
315315
end
316316

317317
it "includes chef-ice conditional logic" do
318-
expect(install_script).to include('if test "$project" = "chef-ice"')
318+
expect(install_script).to include('if [ "$project" = "chef-ice" ]; then')
319319
end
320320

321321
it "constructs chef-ice metadata URL with m, p, pm parameters" do
322-
expect(install_script).to include('metadata_url="$base_api_url/$channel/$project/metadata?v=$version&license_id=$license_id&m=$machine&p=$platform_param&pm=$package_manager"')
322+
expect(install_script).to include('metadata_url="$base_api_url/$channel/$project/metadata?license_id=$license_id&v=$version&m=$machine&p=$platform_param&pm=$package_manager"')
323323
end
324324

325325
it "uses trial API endpoint" do
@@ -329,7 +329,7 @@
329329
it "works with trial- prefix" do
330330
add_options[:license_id] = "trial-abc-456"
331331
expect(install_script).to include("https://chefdownload-trial.chef.io")
332-
expect(install_script).to include('if test "$project" = "chef-ice"')
332+
expect(install_script).to include('if [ "$project" = "chef-ice" ]; then')
333333
end
334334
end
335335

@@ -473,7 +473,7 @@
473473
it_behaves_like "the correct ps1 script"
474474

475475
it "includes chef-ice conditional logic" do
476-
expect(install_script).to include("if ($project -eq 'chef-ice' -and $license_id)")
476+
expect(install_script).to include("if ($project -eq 'chef-ice')")
477477
end
478478

479479
it "includes simplified parameters for chef-ice on Windows" do
@@ -482,7 +482,8 @@
482482
end
483483

484484
it "constructs chef-ice metadata URL with m, p, pm parameters" do
485-
expect(install_script).to include('$metadata_array = ("?v=$($version)"')
485+
expect(install_script).to include('$metadata_array = (')
486+
expect(install_script).to include('"?v=$($version)"')
486487
expect(install_script).to include('"license_id=$license_id"')
487488
expect(install_script).to include('"m=$architecture"')
488489
end
@@ -503,7 +504,7 @@
503504
it_behaves_like "the correct ps1 script"
504505

505506
it "includes chef-ice conditional logic" do
506-
expect(install_script).to include("if ($project -eq 'chef-ice' -and $license_id)")
507+
expect(install_script).to include("if ($project -eq 'chef-ice')")
507508
end
508509

509510
it "includes simplified parameters for chef-ice on Windows" do
@@ -665,7 +666,7 @@
665666
end
666667

667668
it "includes checksum verification check" do
668-
expect(install_script).to match(/if test "x\$sha256" = "x"; then/)
669+
expect(install_script).to match(/if \[ -z "\$sha256" \]; then/)
669670
end
670671
end
671672
end

0 commit comments

Comments
 (0)