| 1 |
# frozen_string_literal: true |
| 2 |
|
| 3 |
require 'spec_helper_acceptance' |
| 4 |
|
| 5 |
describe 'redis' do |
| 6 |
redis_name = fact('os.family') == 'Debian' ? 'redis-server' : 'redis' |
| 7 |
|
| 8 |
include_examples 'an idempotent resource' do |
| 9 |
let(:manifest) { 'include redis' } |
| 10 |
end |
| 11 |
|
| 12 |
it 'returns a fact' do |
| 13 |
pp = <<-EOS |
| 14 |
notify{"Redis Version: ${::redis_server_version}":} |
| 15 |
EOS |
| 16 |
|
| 17 |
# Check output for fact string |
| 18 |
apply_manifest(pp, catch_failures: true) do |r| |
| 19 |
expect(r.stdout).to match(%r{Redis Version: [\d+.]+}) |
| 20 |
end |
| 21 |
end |
| 22 |
|
| 23 |
specify { expect(package(redis_name)).to be_installed } |
| 24 |
specify { expect(service(redis_name)).to be_running } |
| 25 |
|
| 26 |
specify 'redis should respond to ping command' do |
| 27 |
expect(command('redis-cli ping')). |
| 28 |
to have_attributes(stdout: %r{PONG}) |
| 29 |
end |
| 30 |
|
| 31 |
it 'runs successfully when using Redis apt repository', if: (fact('os.family') == 'Debian') do |
| 32 |
pp = <<-EOS |
| 33 |
class { 'redis': |
| 34 |
manage_repo => true, |
| 35 |
redis_apt_repo => true, |
| 36 |
} |
| 37 |
EOS |
| 38 |
|
| 39 |
# Apply twice to ensure no errors the second time. |
| 40 |
apply_manifest(pp, catch_failures: true) |
| 41 |
apply_manifest(pp, catch_changes: true) |
| 42 |
end |
| 43 |
end |