---
- name: ensure Chocolatey is installed
  win_chocolatey:
    name: chocolatey
    state: present

- name: remove original Chocolatey source at the start of the test
  win_chocolatey_source:
    name: Chocolatey
    state: absent

- name: ensure test Chocolatey source is removed
  win_chocolatey_source:
    name: '{{ test_chocolatey_name }}'
    state: absent

- block:
  - name: run tests
    include_tasks: tests.yml

  always:
  - name: ensure original Chocolatey source is re-added
    win_chocolatey_source:
      name: Chocolatey
      source: https://chocolatey.org/api/v2/
      state: present

  - name: remove test Chocolatey source
    win_chocolatey_source:
      name: '{{ test_chocolatey_name }}'
      state: absent