Sha256: 5f45ed5160bb61fd250e82212c5e50221f97bbf6bff03b6b481aa024b0840030

Contents?: true

Size: 1.6 KB

Versions: 14

Compression:

Stored size: 1.6 KB

Contents

require 'spec_helper_system'

describe 'mysql::db define' do
  describe 'creating a database' do
    # Using puppet_apply as a helper
    it 'should work with no errors' do
      pp = <<-EOS
        class { 'mysql::server': override_options => { 'root_password' => 'password' } }
        mysql::db { 'spec1':
          user     => 'root1',
          password => 'password',
        }
      EOS

      # Run it twice and test for idempotency
      puppet_apply(pp) do |r|
        [0,2].should include r.exit_code
        r.refresh
        r.exit_code.should be_zero
      end
    end

    it 'should have the database' do
      shell("mysql -e 'show databases;'|grep spec1") do |s|
        s.exit_code.should be_zero
      end
    end
  end

  describe 'creating a database with post-sql' do
    # Using puppet_apply as a helper
    it 'should work with no errors' do
      pp = <<-EOS
        class { 'mysql::server': override_options => { 'root_password' => 'password' } }
        file { '/tmp/spec.sql':
          ensure  => file,
          content => 'CREATE TABLE table1 (id int);',
          before  => Mysql::Db['spec2'],
        }
        mysql::db { 'spec2':
          user     => 'root1',
          password => 'password',
          sql      => '/tmp/spec.sql',
        }
      EOS

      # Run it twice and test for idempotency
      puppet_apply(pp) do |r|
        [0,2].should include r.exit_code
        r.refresh
        r.exit_code.should be_zero
      end
    end

    it 'should have the table' do
      shell("mysql -e 'show tables;' spec2|grep table1") do |s|
        s.exit_code.should == 0
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

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