<commit_before>require 'spec_helper_acceptance'

describe 'postgresql::server::recovery', unless: UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
  describe 'should manage recovery' do
    after(:all) do
      pp = <<-MANIFEST.unindent
        file { '/tmp/recovery.conf':
          ensure => absent,
        }
      MANIFEST

      apply_manifest(pp, catch_failures: true)
    end

    pp = <<-MANIFEST.unindent
      class { 'postgresql::globals':
        recovery_conf_path => '/tmp/recovery.conf',
        manage_recovery_conf => true,
      }

      class { 'postgresql::server': }

      # Create a recovery.conf file
      postgresql::server::recovery { "recovery.conf":
        restore_command          => 'restore_command',
        recovery_target_timeline => 'recovery_target_timeline',
      }
    MANIFEST
    it 'adds conf file' do
      apply_manifest(pp, catch_failures: true)
      apply_manifest(pp, catch_changes: true)
    end

    describe file('/tmp/recovery.conf') do
      it { is_expected.to be_file }
      it { is_expected.to contain %r{restore_command = 'restore_command'} }
      it { is_expected.to contain %r{recovery_target_timeline = 'recovery_target_timeline'} }
    end
  end

  describe 'should not create recovery if recovery config not specified' do
    after(:all) do
      pp = <<-EOS.unindent
        file { '/tmp/recovery.conf':
          ensure => absent,
        }
      EOS

      apply_manifest(pp, :catch_failures => true)
    end

    it 'does not add conf file' do
      pp = <<-EOS.unindent
        class { 'postgresql::globals':
          recovery_conf_path => '/tmp/recovery.conf',
          manage_recovery_conf => true,
        }

        class { 'postgresql::server': }
      EOS

      apply_manifest(pp, :catch_failures => true)
      apply_manifest(pp, :catch_changes => true)
    end

    describe file('/tmp/recovery.conf') do
      it { is_expected.not_to be_file }
    end
  end<commit_msg>(MODULES-4276) Update for Ruby 1.9 hash syntax<commit_after>require 'spec_helper_acceptance'

describe 'postgresql::server::recovery', unless: UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
  describe 'should manage recovery' do
    after(:all) do
      pp = <<-MANIFEST.unindent
        file { '/tmp/recovery.conf':
          ensure => absent,
        }
      MANIFEST

      apply_manifest(pp, catch_failures: true)
    end

    pp = <<-MANIFEST.unindent
      class { 'postgresql::globals':
        recovery_conf_path => '/tmp/recovery.conf',
        manage_recovery_conf => true,
      }

      class { 'postgresql::server': }

      # Create a recovery.conf file
      postgresql::server::recovery { "recovery.conf":
        restore_command          => 'restore_command',
        recovery_target_timeline => 'recovery_target_timeline',
      }
    MANIFEST
    it 'adds conf file' do
      apply_manifest(pp, catch_failures: true)
      apply_manifest(pp, catch_changes: true)
    end

    describe file('/tmp/recovery.conf') do
      it { is_expected.to be_file }
      it { is_expected.to contain %r{restore_command = 'restore_command'} }
      it { is_expected.to contain %r{recovery_target_timeline = 'recovery_target_timeline'} }
    end
  end

  describe 'should not create recovery if recovery config not specified' do
    after(:all) do
      pp = <<-EOS.unindent
        file { '/tmp/recovery.conf':
          ensure => absent,
        }
      EOS

      apply_manifest(pp, catch_failures: true)
    end

    it 'does not add conf file' do
      pp = <<-EOS.unindent
        class { 'postgresql::globals':
          recovery_conf_path => '/tmp/recovery.conf',
          manage_recovery_conf => true,
        }

        class { 'postgresql::server': }
      EOS

      apply_manifest(pp, catch_failures: true)
      apply_manifest(pp, catch_changes: true)
    end

    describe file('/tmp/recovery.conf') do
      it { is_expected.not_to be_file }
    end
  end
{'fraction_non_alphanumeric': 0.10981189628876462, 'fraction_numerical': 0.001525165226232842, 'mean_word_length': 2.557866184448463, 'pattern_counts': {'":': 2, '<': 19, '<?xml version=': 0, '>': 22, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3818356', 'n_tokens_mistral': 1266, 'n_tokens_neox': 1231, 'n_words': 271}