<commit_before>require 'spec_helper'

describe 'redis::instance', :type => 'define' do
  let(:title) { 'redis-instance' }

  context "On Debian systems with default parameters" do
    let :facts do
      {
        :osfamily => 'Debian'
      }
    end # let

    it do
      should contain_file('redis_port_6379.conf').with_content(/^port 6379$/)
      should contain_file('redis_port_6379.conf').with_content(/^save 900 1$/)
      should contain_file('redis_port_6379.conf').with_content(/^save 300 10$/)
      should contain_file('redis_port_6379.conf').with_content(/^save 60 10000$/)
    end # it
  end # context

  context "On Debian systems with no password parameter" do

    let :facts do
      {
        :osfamily  => 'Debian'
      }
    end # let

    let :params do
      {
        :redis_password => false
      }
    end # let

    it do
      should contain_file('redis_port_6379.conf').without_content(/^requirepass/)
    end # it
  end # context

  context "On Debian systems with password parameter" do

    let :facts do
      {
        :osfamily  => 'Debian'
      }
    end # let

    let :params do
      {
        :redis_port     => '6900',
        :redis_password => '<PASSWORD>'
      }
    end # let

    it do
      should contain_file('redis_port_6900.conf').with_content(/^requirepass ThisIsAReallyBigSecret/)
      should contain_file('redis-init-6900').with_content(/^CLIEXEC="[\w\/]+redis-cli -h \$REDIS_BIND_ADDRESS -p \$REDIS_PORT -a ThisIsAReallyBigSecret/)
    end # it
  end # context

  context "With a non-default port parameter" do
    let :facts do
      {
        :osfamily => 'Debian'
      }
    end # let
    let :params do
      {
        :redis_port => '6900'
      }
    end # let

    it do
      should contain_file('redis_port_6900.conf').with_content(/^port 6900$/)
      should contain_file('redis_port_6900.conf').with_content(/^pidfile \/var\/run\/redis_6900\.pid$/)
      should contain_file('redis_port_6900.conf').with_content(/^logfile \/var\/log\/redis_6900\.log$/)
      should contain_file('redis_port_6900.conf').with_content(/^dir \/var\/lib\/redis\/6900$/)
      should contain_file('redis-init-6900').with_content(/^REDIS_PORT="6900"$/)
    end # it
  end # context

  context "With a non default bind address" do
    let :facts do
      {
        :osfamily => 'Debian'
      }
    end # let
    let :params do
      {
        :redis_port => '6900',
        :redis_bind_address => '10.1.2.3'
      }
    end # let

    it do
      should contain_file('redis_port_6900.conf').with_content(/^bind 10\.1\.2\.3$/)<commit_msg>Cleanup tests and add some compile checks.<commit_after>require 'spec_helper'

describe 'redis::instance', :type => 'define' do
  let(:title) { 'redis-instance' }

  let :facts do
    {
      :osfamily  => 'RedHat'
    }
  end # let

  context "On Debian systems with default parameters" do
    it do
      should contain_file('redis_port_6379.conf').with_content(/^port 6379$/)
      should contain_file('redis_port_6379.conf').with_content(/^save 900 1$/)
      should contain_file('redis_port_6379.conf').with_content(/^save 300 10$/)
      should contain_file('redis_port_6379.conf').with_content(/^save 60 10000$/)
    end # it
  end # context

  context "On Debian systems with no password parameter" do
    let :params do
      {
        :redis_password => false
      }
    end # let

    it do
      should contain_file('redis_port_6379.conf').without_content(/^requirepass/)
    end # it
  end # context

  context "On Debian systems with password parameter" do
    let :params do
      {
        :redis_port     => '6900',
        :redis_password => '<PASSWORD>'
      }
    end # let

    it do
      should compile.with_all_deps

      should contain_file('redis_port_6900.conf').with_content(/^requirepass ThisIsAReallyBigSecret/)
      should contain_file('redis-init-6900').with_content(/^CLIEXEC="[\w\/]+redis-cli -h \$REDIS_BIND_ADDRESS -p \$REDIS_PORT -a ThisIsAReallyBigSecret/)
    end # it
  end # context

  context "With a non-default port parameter" do
    let :params do
      {
        :redis_port => '6900'
      }
    end # let

    it do
      should compile.with_all_deps

      should contain_file('redis_port_6900.conf').with_content(/^port 6900$/)
      should contain_file('redis_port_6900.conf').with_content(/^pidfile \/var\/run\/redis_6900\.pid$/)
      should contain_file('redis_port_6900.conf').with_content(/^logfile \/var\/log\/redis_6900\.log$/)
      should contain_file('redis_port_6900.conf').with_content(/^dir \/var\/lib\/redis\/6900$/)
      should contain_file('redis-init-6900').with_content(/^REDIS_PORT="6900"$/)
    end # it
  end # context

  context "With a non default bind address" do
    let :params do
      {
        :redis_port => '6900',
        :redis_bind_address => '10.1.2.3'
      }
    end # let

    it do
      should compile.with_all_deps

      should contain_file('redis_port_6900.conf').with_content(/^bind 10\.1\.2\.3$/)
{'fraction_non_alphanumeric': 0.13081861958266452, 'fraction_numerical': 0.045746388443017656, 'mean_word_length': 2.6149383611312547, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '4096338', 'n_tokens_mistral': 1873, 'n_tokens_neox': 1682, 'n_words': 357}