|
261 | 261 | end |
262 | 262 |
|
263 | 263 | it 'sets platform globals' do |
264 | | - output, status = test(<<~EOT) |
265 | | - set_platform_globals |
266 | | - echo "set platform=$platform" |
267 | | - echo "set os_full_version=$os_full_version" |
268 | | - echo "set os_major_version=$os_major_version" |
269 | | - echo "set os_family=$os_family" |
270 | | - EOT |
| 264 | + output, status = test('set_platform_globals') |
271 | 265 |
|
272 | 266 | expect(status.success?).to be(true) |
273 | | - expect(output).to include('set platform=Ubuntu') |
274 | | - expect(output).to include('set os_full_version=24.04') |
275 | | - expect(output).to include('set os_major_version=24') |
276 | | - expect(output).to include('set os_family=ubuntu') |
| 267 | + expect(output).to include('Assigned platform=Ubuntu') |
| 268 | + expect(output).to include('Assigned os_full_version=24.04') |
| 269 | + expect(output).to include('Assigned os_major_version=24') |
| 270 | + expect(output).to include('Assigned os_family=ubuntu') |
277 | 271 | end |
278 | 272 |
|
279 | 273 | context 'with a pre-release' do |
280 | 274 | let(:os) { :debian13 } |
281 | 275 |
|
282 | 276 | it 'uses codename when release is n/a' do |
283 | | - output, status = test(<<~EOT) |
284 | | - set_platform_globals |
285 | | - echo "set platform=$platform" |
286 | | - echo "set os_full_version=$os_full_version" |
287 | | - echo "set os_major_version=$os_major_version" |
288 | | - echo "set os_family=$os_family" |
289 | | - EOT |
| 277 | + output, status = test('set_platform_globals') |
290 | 278 |
|
291 | 279 | expect(status.success?).to be(true) |
292 | | - expect(output).to include('set platform=Debian') |
293 | | - expect(output).to include('set os_full_version=13') |
294 | | - expect(output).to include('set os_major_version=13') |
295 | | - expect(output).to include('set os_family=debian') |
| 280 | + expect(output).to include('Assigned platform=Debian') |
| 281 | + expect(output).to include('Assigned os_full_version=13') |
| 282 | + expect(output).to include('Assigned os_major_version=13') |
| 283 | + expect(output).to include('Assigned os_family=debian') |
296 | 284 | end |
297 | 285 | end |
298 | 286 | end |
|
308 | 296 | it 'fails for an unknown platform' do |
309 | 297 | mock_facts_task_bash_sh(:unknown) |
310 | 298 |
|
311 | | - output, status = test(<<~EOT) |
312 | | - set_platform_globals |
313 | | - echo "set platform=$platform" |
314 | | - echo "set os_full_version=$os_full_version" |
315 | | - echo "set os_major_version=$os_major_version" |
316 | | - echo "set os_family=$os_family" |
317 | | - EOT |
| 299 | + output, status = test('set_platform_globals') |
318 | 300 |
|
319 | 301 | expect(status.success?).to be(false) |
320 | 302 | expect(output).to include("Unhandled platform: 'Unknown'") |
|
439 | 421 | end |
440 | 422 | end |
441 | 423 | end |
| 424 | + |
| 425 | + context 'noarch_package' do |
| 426 | + it 'returns 0 for a noarch package' do |
| 427 | + output, status = test('noarch_package openvox-server') |
| 428 | + |
| 429 | + expect(status.success?).to be(true) |
| 430 | + expect(output.strip).to be_empty |
| 431 | + end |
| 432 | + |
| 433 | + it 'returns 1 for a non-noarch package' do |
| 434 | + output, status = test('noarch_package foo') |
| 435 | + |
| 436 | + expect(status.success?).to be(false) |
| 437 | + expect(output.strip).to be_empty |
| 438 | + end |
| 439 | + end |
| 440 | + |
| 441 | + context 'set_cpu_architecture' do |
| 442 | + context 'debian or ubuntu' do |
| 443 | + it 'sets x86_64 for amd64' do |
| 444 | + allow_script.to receive_command(:uname).and_exec('echo x86_64') |
| 445 | + output, status = test('set_cpu_architecture debian') |
| 446 | + |
| 447 | + expect(status.success?).to be(true) |
| 448 | + expect(output).to include('Assigned cpu_arch=amd64') |
| 449 | + end |
| 450 | + |
| 451 | + it 'sets arm64 for aarch64' do |
| 452 | + allow_script.to receive_command(:uname).and_exec('echo aarch64') |
| 453 | + output, status = test('set_cpu_architecture ubuntu') |
| 454 | + |
| 455 | + expect(status.success?).to be(true) |
| 456 | + expect(output).to include('Assigned cpu_arch=arm64') |
| 457 | + end |
| 458 | + |
| 459 | + it 'sets amd64 for amd64' do |
| 460 | + allow_script.to receive_command(:uname).and_exec('echo amd64') |
| 461 | + output, status = test('set_cpu_architecture debian') |
| 462 | + |
| 463 | + expect(status.success?).to be(true) |
| 464 | + expect(output).to include('Assigned cpu_arch=amd64') |
| 465 | + end |
| 466 | + end |
| 467 | + |
| 468 | + context 'other' do |
| 469 | + it 'sets what uname gives it' do |
| 470 | + allow_script.to receive_command(:uname).and_exec('echo x86_64') |
| 471 | + output, status = test('set_cpu_architecture el') |
| 472 | + |
| 473 | + expect(status.success?).to be(true) |
| 474 | + expect(output).to include('Assigned cpu_arch=x86_64') |
| 475 | + end |
| 476 | + end |
| 477 | + end |
| 478 | + |
| 479 | + context 'set_package_architecture' do |
| 480 | + it 'sets all for debian noarch' do |
| 481 | + output, status = test('set_package_architecture openvox-server debian') |
| 482 | + |
| 483 | + expect(status.success?).to be(true) |
| 484 | + expect(output).to include('Assigned package_arch=all') |
| 485 | + end |
| 486 | + |
| 487 | + it 'sets noarch for el noarch' do |
| 488 | + output, status = test('set_package_architecture openvoxdb el') |
| 489 | + |
| 490 | + expect(status.success?).to be(true) |
| 491 | + expect(output).to include('Assigned package_arch=noarch') |
| 492 | + end |
| 493 | + |
| 494 | + it 'sets system arch otherwise' do |
| 495 | + allow_script.to receive_command(:uname).and_exec('echo x86_64') |
| 496 | + output, status = test('set_package_architecture openvox-agent el') |
| 497 | + |
| 498 | + expect(status.success?).to be(true) |
| 499 | + expect(output).to include('Assigned cpu_arch=x86_64') |
| 500 | + expect(output).to include('Assigned package_arch=x86_64') |
| 501 | + end |
| 502 | + end |
| 503 | + |
| 504 | + context 'set_artifacts_package_url' do |
| 505 | + context 'deb' do |
| 506 | + it 'builds a debian url' do |
| 507 | + allow_script.to set_env('os_family', 'debian') |
| 508 | + allow_script.to receive_command(:uname).and_exec('echo x86_64') |
| 509 | + output, status = test('set_artifacts_package_url https://foo openvox-agent 8.18.0') |
| 510 | + |
| 511 | + expect(status.success?).to be(true) |
| 512 | + package_name = 'openvox-agent_8.18.0-1%2Bdebian_amd64.deb' |
| 513 | + expect(output).to include("Assigned package_name=#{package_name}") |
| 514 | + expect(output).to include("Assigned package_url=https://foo/openvox-agent/8.18.0/#{package_name}") |
| 515 | + end |
| 516 | + |
| 517 | + it 'builds a noarch package url for ubuntu' do |
| 518 | + allow_script.to set_env('os_family', 'ubuntu') |
| 519 | + output, status = test('set_artifacts_package_url https://foo openvox-server 8.9.0') |
| 520 | + |
| 521 | + expect(status.success?).to be(true) |
| 522 | + package_name = 'openvox-server_8.9.0-1%2Bubuntu_all.deb' |
| 523 | + expect(output).to include("Assigned package_name=#{package_name}") |
| 524 | + expect(output).to include("Assigned package_url=https://foo/openvox-server/8.9.0/#{package_name}") |
| 525 | + end |
| 526 | + end |
| 527 | + |
| 528 | + context 'rpm' do |
| 529 | + it 'builds a redhat url' do |
| 530 | + allow_script.to set_env('os_family', 'el') |
| 531 | + allow_script.to receive_command(:uname).and_exec('echo x86_64') |
| 532 | + output, status = test('set_artifacts_package_url https://foo openvox-agent 8.18.0') |
| 533 | + |
| 534 | + expect(status.success?).to be(true) |
| 535 | + package_name = 'openvox-agent-8.18.0-1.el.x86_64.rpm' |
| 536 | + expect(output).to include("Assigned package_name=#{package_name}") |
| 537 | + expect(output).to include("Assigned package_url=https://foo/openvox-agent/8.18.0/#{package_name}") |
| 538 | + end |
| 539 | + |
| 540 | + it 'builds a noarch package url for redhat' do |
| 541 | + allow_script.to set_env('os_family', 'el') |
| 542 | + output, status = test('set_artifacts_package_url https://foo openvoxdb-termini 8.9.1') |
| 543 | + |
| 544 | + expect(status.success?).to be(true) |
| 545 | + package_name = 'openvoxdb-termini-8.9.1-1.el.noarch.rpm' |
| 546 | + expect(output).to include("Assigned package_name=#{package_name}") |
| 547 | + expect(output).to include("Assigned package_url=https://foo/openvoxdb-termini/8.9.1/#{package_name}") |
| 548 | + end |
| 549 | + |
| 550 | + it 'builds a fedora url' do |
| 551 | + allow_script.to set_env('os_family', 'fedora') |
| 552 | + allow_script.to receive_command(:uname).and_exec('echo x86_64') |
| 553 | + output, status = test('set_artifacts_package_url https://foo openvox-agent 8.18.0') |
| 554 | + |
| 555 | + expect(status.success?).to be(true) |
| 556 | + package_name = 'openvox-agent-8.18.0-1.fc.x86_64.rpm' |
| 557 | + expect(output).to include("Assigned package_name=#{package_name}") |
| 558 | + expect(output).to include("Assigned package_url=https://foo/openvox-agent/8.18.0/#{package_name}") |
| 559 | + end |
| 560 | + end |
| 561 | + end |
442 | 562 | end |
0 commit comments