Adding molecule unit tests
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
---
|
||||
- name: Verify nextcloud role
|
||||
hosts: localhost
|
||||
gather_facts: false
|
||||
vars:
|
||||
nextcloud_data_dir: /tmp/sovereign_test/nextcloud
|
||||
|
||||
tasks:
|
||||
- name: Check nextcloud data directory exists
|
||||
ansible.builtin.stat:
|
||||
path: /tmp/sovereign_test/nextcloud
|
||||
register: data_dir_stat
|
||||
|
||||
- name: Assert nextcloud data directory is present
|
||||
ansible.builtin.assert:
|
||||
that: data_dir_stat.stat.isdir
|
||||
fail_msg: "Data directory /tmp/sovereign_test/nextcloud was not created"
|
||||
|
||||
- name: Check nextcloud data subdirectory exists
|
||||
ansible.builtin.stat:
|
||||
path: /tmp/sovereign_test/nextcloud/data
|
||||
register: data_subdir_stat
|
||||
|
||||
- name: Assert nextcloud data subdirectory is present
|
||||
ansible.builtin.assert:
|
||||
that: data_subdir_stat.stat.isdir
|
||||
fail_msg: "Directory /tmp/sovereign_test/nextcloud/data was not created"
|
||||
|
||||
- name: Check docker-compose.yml exists
|
||||
ansible.builtin.stat:
|
||||
path: /tmp/sovereign_test/nextcloud/docker-compose.yml
|
||||
register: compose_stat
|
||||
|
||||
- name: Assert docker-compose.yml was rendered
|
||||
ansible.builtin.assert:
|
||||
that: compose_stat.stat.exists
|
||||
fail_msg: "docker-compose.yml was not rendered for nextcloud"
|
||||
|
||||
- name: Read docker-compose.yml
|
||||
ansible.builtin.slurp:
|
||||
src: /tmp/sovereign_test/nextcloud/docker-compose.yml
|
||||
register: compose_raw
|
||||
|
||||
- name: Set compose content fact
|
||||
ansible.builtin.set_fact:
|
||||
compose: "{{ compose_raw.content | b64decode }}"
|
||||
|
||||
- name: Assert nextcloud image reference in compose
|
||||
ansible.builtin.assert:
|
||||
that: "'nextcloud:29' in compose"
|
||||
fail_msg: "Expected image 'nextcloud:29' not found in docker-compose.yml"
|
||||
|
||||
- name: Assert nextcloud host rule in compose
|
||||
ansible.builtin.assert:
|
||||
that: "'Host(`cloud.test.example.com`)' in compose"
|
||||
fail_msg: "Expected Host rule for cloud.test.example.com not found in docker-compose.yml"
|
||||
|
||||
- name: Assert GELF logging address in compose
|
||||
ansible.builtin.assert:
|
||||
that: "'udp://127.0.0.1:12201' in compose"
|
||||
fail_msg: "Expected GELF address udp://127.0.0.1:12201 not found in docker-compose.yml"
|
||||
|
||||
- name: Assert sovereign network is external in compose
|
||||
ansible.builtin.assert:
|
||||
that: "'external: true' in compose"
|
||||
fail_msg: "Expected 'external: true' not found in docker-compose.yml"
|
||||
|
||||
- name: Assert nextcloud db password in compose
|
||||
ansible.builtin.assert:
|
||||
that: "'test_nextcloud_db' in compose"
|
||||
fail_msg: "Expected nextcloud_db_password 'test_nextcloud_db' not found in docker-compose.yml"
|
||||
|
||||
- name: Assert nextcloud S3 secret key in compose
|
||||
ansible.builtin.assert:
|
||||
that: "'test_nextcloud_s3' in compose"
|
||||
fail_msg: "Expected minio_nextcloud_secret_key 'test_nextcloud_s3' not found in docker-compose.yml"
|
||||
Reference in New Issue
Block a user