Sha256: e63334f3ceaf569a748aeb307dc380470774f1c10eb0455e093c90d046e6c7e4

Contents?: true

Size: 1.23 KB

Versions: 7

Compression:

Stored size: 1.23 KB

Contents

require 'spec_helper_system'

describe 'postgresql_psql:' do
  after :all do
    # Cleanup after tests have ran
    puppet_apply("class { 'postgresql::server': ensure => absent }") do |r|
      r.exit_code.should_not == 1
    end
  end

  it 'should run some SQL when the unless query returns no rows' do
    pp = <<-EOS.unindent
      class { 'postgresql::server': }

      postgresql_psql { 'foobar':
        db        => 'postgres',
        psql_user => 'postgres',
        command   => 'select 1',
        unless    => 'select 1 where 1=2',
        require   => Class['postgresql::server'],
      }
    EOS

    puppet_apply(pp) do |r|
      r.exit_code.should_not == 1
      r.refresh
      r.exit_code.should == 2
    end
  end

  it 'should not run SQL when the unless query returns rows' do
    pp = <<-EOS.unindent
      class { 'postgresql::server': }

      postgresql_psql { 'foobar':
        db        => 'postgres',
        psql_user => 'postgres',
        command   => 'select * from pg_database limit 1',
        unless    => 'select 1 where 1=1',
        require   => Class['postgresql::server'],
      }
    EOS

    puppet_apply(pp) do |r|
      r.exit_code.should_not == 1
      r.refresh
      r.exit_code.should == 0
    end
  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
freighthop-0.3.3 modules/postgresql/spec/system/postgresql_psql_spec.rb
freighthop-0.3.2 modules/postgresql/spec/system/postgresql_psql_spec.rb
freighthop-0.3.1 modules/postgresql/spec/system/postgresql_psql_spec.rb
freighthop-0.3.0 modules/postgresql/spec/system/postgresql_psql_spec.rb
freighthop-0.2.1 modules/postgresql/spec/system/postgresql_psql_spec.rb
freighthop-0.2.0 modules/postgresql/spec/system/postgresql_psql_spec.rb
freighthop-0.1.0 modules/postgresql/spec/system/postgresql_psql_spec.rb