summaryrefslogtreecommitdiff
path: root/spec/postgres_spec.rb
blob: 989b2b25ea4209558e368982bdb78992ead90cff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
describe "stronglifters::postgres" do
  subject do
    ChefSpec::SoloRunner.new do |node|
      node.set["postgres"]["database"] = database_name
      node.set["postgres"]["host"] = database_host
      node.set["postgres"]["username"] = database_user
      node.set["postgresql"]["password"]['postgres'] = database_password
      node.set["postgresql"]["config"] = {}
      node.set['postgresql']['client']['packages'] = []
      node.set['postgresql']['config']['data_directory'] = "/var/data"
      node.set['postgresql']['contrib']['packages'] = []
    end.converge(described_recipe)
  end

  let(:database_name) { FFaker::Internet.user_name }
  let(:database_host) { "localhost" }
  let(:database_user) { FFaker::Internet.user_name }
  let(:database_password) { "password" }

  before :each do
    stub_command('ls /var/data/recovery.conf').and_return(true)
  end

  it 'creates the specified database' do
    expect(subject).to create_postgresql_database(database_name)
  end

  it 'creates the database user' do
    expect(subject).to create_postgresql_database_user(database_user)
  end

  it 'grants all privileges to the database user' do
    expect(subject).to grant_postgresql_database_user(database_user)
      .with_privileges([:all])
  end
end