|
577 | 577 | end |
578 | 578 | end |
579 | 579 | end |
| 580 | + |
| 581 | + context 'stop_and_disable_service' do |
| 582 | + it 'fails for an unknown package' do |
| 583 | + output, status = test('stop_and_disable_service unknown-package') |
| 584 | + |
| 585 | + expect(status.success?).to be(false) |
| 586 | + expect(output.strip).to include("Unknown service for package: 'unknown-package'") |
| 587 | + end |
| 588 | + |
| 589 | + it 'fails if puppet executable not found' do |
| 590 | + output, status = test('stop_and_disable_service openvox-agent /no/openvox') |
| 591 | + |
| 592 | + expect(status.success?).to be(false) |
| 593 | + expect(output.strip).to include("Puppet executable not found at '/no/openvox'") |
| 594 | + end |
| 595 | + |
| 596 | + context 'with puppet executable' do |
| 597 | + let(:mock_puppet) { "#{tmpdir}/puppet" } |
| 598 | + |
| 599 | + before do |
| 600 | + # The little BashRspec lib isn't sophisticated enough |
| 601 | + # to deal with an absolute path, so using this instead of |
| 602 | + # allow_script.to receive_command(mock_puppet)... |
| 603 | + File.write(mock_puppet, <<~EOF) |
| 604 | + #!/bin/sh |
| 605 | + echo "Stopping ${3} service" |
| 606 | + EOF |
| 607 | + File.chmod(0o755, mock_puppet) |
| 608 | + end |
| 609 | + |
| 610 | + [ |
| 611 | + %w[openvox-agent puppet], |
| 612 | + %w[openvox-server puppetserver], |
| 613 | + %w[openvoxdb puppetdb], |
| 614 | + ].each do |package, service| |
| 615 | + it "stops the #{service} service for #{package}" do |
| 616 | + output, status = test("stop_and_disable_service #{package} #{mock_puppet}") |
| 617 | + |
| 618 | + expect(status.success?).to be(true) |
| 619 | + expect(output.strip).to include(service) |
| 620 | + end |
| 621 | + end |
| 622 | + end |
| 623 | + end |
580 | 624 | end |
0 commit comments