# Copyright (c) 2018, Yanis Guenane <yanis+ansible@guenane.org>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
---
- name: test gather vultr block storage volume info - empty resource
  vultr_block_storage_info:

- name: Create the block storage volume
  vultr_block_storage:
    name: '{{ vultr_block_storage_name }}'
    size: '{{ vultr_block_storage_size }}'
    region: '{{ vultr_block_storage_region }}'

- name: test gather vultr block storage volume info in check mode
  vultr_block_storage_info:
  check_mode: yes
  register: result

- name: verify test gather vultr block storage volume info in check mode
  assert:
    that:
    - result.vultr_block_storage_info|selectattr('name','equalto','{{ vultr_block_storage_name }}') | list | count == 1

- name: test gather vultr block storage volume info
  vultr_block_storage_info:
  register: result

- name: verify test gather vultr block storage volume info
  assert:
    that:
    - result.vultr_block_storage_info|selectattr('name','equalto','{{ vultr_block_storage_name }}') | list | count == 1

- name: Delete the block storage volume
  vultr_block_storage:
    name: '{{ vultr_block_storage_name }}'
    state: absent
