Commit 30e2eb7ce8fa951da733a61bcc17d002811ce652
1 parent
89913b1f
Exists in
master
and in
90 other branches
PostreSQL: create colab database
Showing
3 changed files
with
21 additions
and
1 deletions
Show diff stats
config/roles/database_server.rb
... | ... | @@ -0,0 +1,16 @@ |
1 | +execute 'createuser:colab' do | |
2 | + command 'createuser colab' | |
3 | + user 'postgres' | |
4 | + only_if do | |
5 | + `sudo -u postgres -i psql --quiet --tuples-only -c "select count(*) from pg_user where usename = 'colab';"`.strip.to_i == 0 | |
6 | + end | |
7 | +end | |
8 | + | |
9 | +execute 'createdb:colab' do | |
10 | + command 'createdb --owner=colab colab' | |
11 | + user 'postgres' | |
12 | + only_if do | |
13 | + `sudo -u postgres -i psql --quiet --tuples-only -c "select count(1) from pg_database where datname = 'colab';"`.strip.to_i == 0 | |
14 | + end | |
15 | +end | |
16 | + | ... | ... |
test/postgresql_test.sh
... | ... | @@ -4,5 +4,9 @@ test_postgresql_running() { |
4 | 4 | assertTrue 'PostgreSQL running' 'run_on database pgrep -fa postgres' |
5 | 5 | } |
6 | 6 | |
7 | +test_colab_database_created() { | |
8 | + assertTrue 'colab database created in PostgreSQL' 'run_on database sudo -u postgres -i psql colab < /dev/null' | |
9 | +} | |
10 | + | |
7 | 11 | . shunit2 |
8 | 12 | ... | ... |