lookup: lmdb_kv: add tests
This commit is contained in:
parent
a2270ead2f
commit
6370c63efc
5 changed files with 63 additions and 0 deletions
2
test/integration/targets/lookup_lmdb_kv/aliases
Normal file
2
test/integration/targets/lookup_lmdb_kv/aliases
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
shippable/posix/group2
|
||||||
|
destructive
|
10
test/integration/targets/lookup_lmdb_kv/dependencies.yml
Normal file
10
test/integration/targets/lookup_lmdb_kv/dependencies.yml
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
---
|
||||||
|
- hosts: localhost
|
||||||
|
tasks:
|
||||||
|
- name: Install LMDB Python package
|
||||||
|
pip:
|
||||||
|
name: lmdb
|
||||||
|
- name: Setup test data
|
||||||
|
script: test_db.py
|
||||||
|
args:
|
||||||
|
executable: "{{ ansible_python.executable }}"
|
9
test/integration/targets/lookup_lmdb_kv/runme.sh
Executable file
9
test/integration/targets/lookup_lmdb_kv/runme.sh
Executable file
|
@ -0,0 +1,9 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
|
set -eux
|
||||||
|
|
||||||
|
ANSIBLE_ROLES_PATH=../ \
|
||||||
|
ansible-playbook dependencies.yml -v "$@"
|
||||||
|
|
||||||
|
ANSIBLE_ROLES_PATH=../ \
|
||||||
|
ansible-playbook test.yml -v "$@"
|
31
test/integration/targets/lookup_lmdb_kv/test.yml
Normal file
31
test/integration/targets/lookup_lmdb_kv/test.yml
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
---
|
||||||
|
- hosts: localhost
|
||||||
|
tasks:
|
||||||
|
- debug:
|
||||||
|
msg: "{{ query('lmdb_kv', 'nl', 'be', 'lu', db='jp.mdb') }}"
|
||||||
|
|
||||||
|
- debug:
|
||||||
|
var: item.1
|
||||||
|
loop: "{{ query('lmdb_kv', db='jp.mdb') }}"
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- query('lmdb_kv', 'nl', 'be', 'lu', db='jp.mdb') == ['Netherlands', 'Belgium', 'Luxembourg']
|
||||||
|
- query('lmdb_kv', db='jp.mdb')|length == 5
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- item.0 == 'nl'
|
||||||
|
- item.1 == 'Netherlands'
|
||||||
|
vars:
|
||||||
|
- lmdb_kv_db: jp.mdb
|
||||||
|
with_lmdb_kv:
|
||||||
|
- "n*"
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- item == 'Belgium'
|
||||||
|
vars:
|
||||||
|
- lmdb_kv_db: jp.mdb
|
||||||
|
with_lmdb_kv:
|
||||||
|
- be
|
11
test/integration/targets/lookup_lmdb_kv/test_db.py
Normal file
11
test/integration/targets/lookup_lmdb_kv/test_db.py
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
from __future__ import (absolute_import, division, print_function)
|
||||||
|
__metaclass__ = type
|
||||||
|
import lmdb
|
||||||
|
map_size = 1024 * 100
|
||||||
|
env = lmdb.open('./jp.mdb', map_size=map_size)
|
||||||
|
with env.begin(write=True) as txn:
|
||||||
|
txn.put('fr'.encode(), 'France'.encode())
|
||||||
|
txn.put('nl'.encode(), 'Netherlands'.encode())
|
||||||
|
txn.put('es'.encode(), 'Spain'.encode())
|
||||||
|
txn.put('be'.encode(), 'Belgium'.encode())
|
||||||
|
txn.put('lu'.encode(), 'Luxembourg'.encode())
|
Loading…
Reference in a new issue