Skip to content

Commit

Permalink
add some tests for future cases
Browse files Browse the repository at this point in the history
  • Loading branch information
mkayontour committed Jan 4, 2024
1 parent fdf0d86 commit bbc5db0
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 0 deletions.
4 changes: 4 additions & 0 deletions molecule/ini-configuration-tests/collections.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
collections:
- name: community.docker
- name: community.general
version: ">=2,<3"
42 changes: 42 additions & 0 deletions molecule/ini-configuration-tests/converge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---

- name: Converge
hosts: all
vars:
test_cases:
- name: string
_i2_config_hash:
section:
test: string
- name: number
_i2_config_hash:
section:
test: 10
- name: advanced_filter
_i2_config_hash:
section:
test: '(objectClass=user)'
test2: "!(objectClass=user)"
test3: "!attribute"
- name: list
_i2_config_hash:
section:
test:
- "foo"
- bar
- 'baz'
- name: equal_sign
_i2_config_hash:
section:
test: 'equal=sign'


collections:
- icinga.icinga
tasks:
- ansible.builtin.template:
src: "{{ lookup('ansible.builtin.env', 'MOLECULE_PROJECT_DIRECTORY', default=Undefined) }}/roles/icingaweb2/templates/modules_config.ini.j2"
dest: "/tmp/{{ item.name }}"
loop: "{{ test_cases }}"
vars:
_i2_config_hash: "{{ item._i2_config_hash }}"
26 changes: 26 additions & 0 deletions molecule/ini-configuration-tests/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
dependency:
name: galaxy
driver:
name: docker
platforms:
- name: icinga-default
image: "geerlingguy/docker-${MOLECULE_DISTRO:-centos7}-ansible:latest"
command: ${MOLECULE_DOCKER_COMMAND:-""}
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
cgroupns_mode: host
privileged: true
pre_build_image: true
provisioner:
name: ansible
inventory:
link:
host_vars: host_vars/
verifier:
name: testinfra
directory: tests/integration/
lint: |
set -e
yamllint --no-warnings roles/
ansible-lint roles/
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
def test_string(host):
i2_file = host.file("/tmp/string")
print(i2_file.content_string)
assert i2_file.is_file
assert i2_file.content_string == "\n[section]\ntest = string"

def test_number(host):
i2_file = host.file("/tmp/number")
print(i2_file.content_string)
assert i2_file.is_file
assert i2_file.content_string == '\n[section]\ntest = "10"'

def test_list(host):
i2_file = host.file("/tmp/list")
print(i2_file.content_string)
assert i2_file.is_file
assert i2_file.content_string == '\n[section]\ntest = "foo, bar, baz"'

def test_advanced_filter(host):
i2_file = host.file("/tmp/advanced_filter")
print(i2_file.content_string)
assert i2_file.is_file
assert i2_file.content_string == "\n[section]\ntest = '!(objectClass=user)'\ntest2 = '!(objectClass=user)'\ntest3 = '!attribute'"

def test_equal_sign(host):
i2_file = host.file("/tmp/equal_sign")
print(i2_file.content_string)
assert i2_file.is_file
assert i2_file.content_string == "\n[section]\ntest = 'equal=sign'"

0 comments on commit bbc5db0

Please sign in to comment.