Skip to content

Commit d9d7585

Browse files
committed
Add basic test of the input file option
1 parent 31f1f24 commit d9d7585

2 files changed

Lines changed: 31 additions & 0 deletions

File tree

tests/simple.sql

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
CREATE TABLE mytable(
2+
mynumber int,
3+
name varchar(255)
4+
);
5+
INSERT INTO mytable VALUES (1, 'test');

tests/tests_input_file.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
- name: Ensure that the role runs with input file
2+
hosts: all
3+
gather_facts: false
4+
5+
tasks:
6+
- name: Run postgresql role with input file
7+
include_role:
8+
name: linux-system-roles.postgresql
9+
vars:
10+
postgresql_input_file: simple.sql
11+
12+
- meta: flush_handlers
13+
14+
- name: Get content of database
15+
become: yes
16+
become_user: postgres
17+
shell: |
18+
set -euo pipefail
19+
echo "SELECT * FROM mytable;" | psql
20+
register: result
21+
changed_when: false
22+
23+
- name: Check content of databse
24+
assert:
25+
that: >
26+
"1 row" in result.stdout

0 commit comments

Comments
 (0)