Sha256: dfbca824edb3898185ddf62386353d7fb2c678a2659a702d3fa8476a26a132af

Contents?: true

Size: 1.74 KB

Versions: 14

Compression:

Stored size: 1.74 KB

Contents

require 'spec_helper'

describe 'mysql::db', :type => :define do
  let(:facts) {{ :osfamily => 'RedHat' }}
  let(:title) { 'test_db' }

  let(:params) {
    { 'user'     => 'testuser',
      'password' => 'testpass',
    }
  }

  it 'should report an error when ensure is not present or absent' do
    params.merge!({'ensure' => 'invalid_val'})
    expect { subject }.to raise_error(Puppet::Error,
      /invalid_val is not supported for ensure\. Allowed values are 'present' and 'absent'\./)
  end

  it 'should not notify the import sql exec if no sql script was provided' do
    should contain_mysql_database('test_db').without_notify
  end

  it 'should subscribe to database if sql script is given' do
    params.merge!({'sql' => 'test_sql'})
    should contain_exec('test_db-import').with_subscribe('Mysql_database[test_db]')
  end

  it 'should only import sql script on creation if not enforcing' do
    params.merge!({'sql' => 'test_sql', 'enforce_sql' => false})
    should contain_exec('test_db-import').with_refreshonly(true)
  end

  it 'should import sql script on creation if enforcing' do
    params.merge!({'sql' => 'test_sql', 'enforce_sql' => true})
    should contain_exec('test_db-import').with_refreshonly(false)
  end

  it 'should not create database and database user' do
    params.merge!({'ensure' => 'absent', 'host' => 'localhost'})
    should contain_mysql_database('test_db').with_ensure('absent')
    should contain_mysql_user('testuser@localhost').with_ensure('absent')
  end

  it 'should create with an appropriate collate and charset' do
    params.merge!({'charset' => 'utf8', 'collate' => 'utf8_danish_ci'})
    should contain_mysql_database('test_db').with({
      'charset' => 'utf8',
      'collate' => 'utf8_danish_ci',
    })
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
freighthop-0.6.1 modules/mysql/spec/defines/mysql_db_spec.rb
freighthop-0.6.0 modules/mysql/spec/defines/mysql_db_spec.rb
freighthop-0.5.2 modules/mysql/spec/defines/mysql_db_spec.rb
freighthop-0.5.1 modules/mysql/spec/defines/mysql_db_spec.rb
freighthop-0.5.0 modules/mysql/spec/defines/mysql_db_spec.rb
freighthop-0.4.1 modules/mysql/spec/defines/mysql_db_spec.rb
freighthop-0.4.0 modules/mysql/spec/defines/mysql_db_spec.rb
freighthop-0.3.3 modules/mysql/spec/defines/mysql_db_spec.rb
freighthop-0.3.2 modules/mysql/spec/defines/mysql_db_spec.rb
freighthop-0.3.1 modules/mysql/spec/defines/mysql_db_spec.rb
freighthop-0.3.0 modules/mysql/spec/defines/mysql_db_spec.rb
freighthop-0.2.1 modules/mysql/spec/defines/mysql_db_spec.rb
freighthop-0.2.0 modules/mysql/spec/defines/mysql_db_spec.rb
freighthop-0.1.0 modules/mysql/spec/defines/mysql_db_spec.rb